<template>
    <div class="app-detail">
        <el-card class="box-card">
            <div class="container-header">
                <div class="hign-line"></div>
                <div class="header-left">
                    {{viewModel.dataSource?viewModel.dataSource:''}}{{$t('inventoryManagement.baseInfo')}}
                </div>
            </div>
            <el-form :model="viewModel" ref="incomingForm" :rules="incommingRules" label-width="108px">
                <el-row :gutter="20" class="mb8">
                    <el-col :span="6">
                        <el-form-item :label="$t('inspectionManagement.sapBatch')" prop="lot">
                            <el-input v-model="viewModel.inspectionLotMark" clearable disabled size="small" @keyup.enter.native="handleQuery" />
                        </el-form-item>
                    </el-col>
                    <!-- <el-col :span="6">
                        <el-form-item label="MSL等级" prop="materialMsl">
                            <el-input v-model="viewModel.materialMsl" disabled clearable size="small" />
                        </el-form-item>
                    </el-col> -->
                    <el-col :span="6">
                        <el-form-item :label="$t('inventoryManagement.materialName')" prop="materialName">
                            <el-input v-model="viewModel.materialName" clearable disabled size="small" @keyup.enter.native="handleQuery" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item :label="$t('inventoryManagement.materialNo')" prop="materialCode">
                            <el-input v-model="viewModel.materialCode" clearable disabled size="small" />
                        </el-form-item>
                    </el-col>
<!--                    <el-col :span="6">-->
<!--                        <el-form-item :label="$t('inspectionManagement.lichn')" prop="lichn">-->
<!--                            <el-input v-model="viewModel.lichn" clearable disabled size="small" />-->
<!--                        </el-form-item>-->
<!--                    </el-col>-->
                    <!-- <el-col :span="6">
                        <el-form-item :label="$t('inventoryManagement.materialType')" prop="materialType">
                            <el-input v-model="viewModel.materialType" disabled size="small" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item label="物料小类" prop="materialMin">
                            <el-input v-model="viewModel.materialMin" disabled size="small" />
                        </el-form-item>
                    </el-col> -->
                    <!-- <el-col :span="6">
                        <el-form-item label="【SAP】成熟度" prop="sapMaturity">
                            <el-input v-model="viewModel.sapMaturity" disabled size="small" />
                        </el-form-item>
                    </el-col> -->

                    <!-- <el-col :span="6">
                        <el-form-item :label="$t('inventoryManagement.maturity')" prop="maturity">
                            <el-input v-model="viewModel.maturity" disabled clearable size="small" />
                        </el-form-item>
                    </el-col> -->

                    <el-col :span="6">
                        <el-form-item :label="$t('inventoryManagement.supplierNo')" prop="supplierCode">
                            <el-input v-model="viewModel.supplierCode" disabled clearable size="small" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item :label="$t('inspectionManagement.oldBatchQuantity')" prop="batchAmount">
                            <el-input disabled v-model="viewModel.batchAmount" clearable size="small" @keyup.enter.native="handleQuery" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item :label="$t('inspectionManagement.oldUnit')" prop="mengeneinh">
                            <el-input v-model="viewModel.mengeneinh" clearable disabled size="small" @keyup.enter.native="handleQuery" />
                        </el-form-item>
                    </el-col>

                    <el-col :span="6">
                        <el-form-item :label="$t('inspectionManagement.factory')" prop="factoryName">
                            <!--                            <span class="size12">{{viewModel.factoryName}}</span>-->
                            <el-input v-model="viewModel.factoryName" disabled clearable size="small" @keyup.enter.native="handleQuery" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item :label="$t('inspectionManagement.reversionBatchQuantity')" prop="amendBatch">
                            <el-input v-model="viewModel.amendBatch" disabled clearable size="small" @keyup.enter.native="handleQuery" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item :label="$t('inspectionManagement.reversionUnit')" prop="amendMeng">
                            <el-input v-model="viewModel.amendMeng" disabled clearable size="small" @keyup.enter.native="handleQuery" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item :label="$t('inspectionManagement.inspectionPlanVersion')" prop="version">
                            <el-input v-model="viewModel.version" disabled clearable size="small" />
                        </el-form-item>
                    </el-col>
                    <!--                    <el-col :span="6">
                        <el-form-item label="卷号" prop="reelNumber">
                            <el-input v-model="viewModel.reelNumber" clearable size="small" />
                        </el-form-item>
                    </el-col>-->

                    <!--                    <el-col :span="6">
                        <el-form-item :label="$t('inspectionManagement.outerPackaging')" prop="outerPacking">
                            <el-select v-model="viewModel.outerPacking" @change="outerPackingChange" :placeholder="$t('public.select_holder',{select_holder: $t('inspectionManagement.outerPackaging')})" style="width:100%;" size="small">
                                <el-option key="0" label="OK" value="0" />
                                <el-option key="1" label="NG" value="1" />
                                <el-option key="NA" label="NA" value="2" />
                            </el-select>
                        </el-form-item>
                    </el-col>-->

                    <el-col :span="6" v-if="viewModel.dataSource==='进料'||viewModel.dataSource==='库存'" style="">
                        <el-form-item :label="$t('inventoryManagement.skipBatchExemptionFromInspection')" prop="exempted" style="width:100%;">
                            <span class="labelN" v-if="viewModel.exempted !== '1'&&viewModel.exempted !== '2'">{{$t('public.no')}}</span>
                            <span class="labelY" v-if="viewModel.exempted === '1'">{{$t('public.yes')}}</span>
                            <span class="labelB" v-if="viewModel.exempted === '2'">{{ $t('inspectionManagement.Inapproval') }}</span>
                        </el-form-item>
                    </el-col>

                    <el-col :span="6">
                        <el-form-item :label="$t('inspectionManagement.COA')" prop="inspectionCoa">
                            <el-select v-model="viewModel.inspectionCoa" @change="inspectionCoaChange"
                            :placeholder="$t('public.select_holder',{select_holder: $t('inspectionManagement.COA')})" style="width:100%;" size="small">
                                <el-option key="0" label="OK" value="0" />
                                <el-option key="1" label="NG" value="1" />
                                <el-option key="NA" label="NA" value="2" />
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item :label="$t('inspectionManage.trialInvestment')" prop="trialInvestment">
                            <el-select v-model="viewModel.trialInvestment" @change="inspectionCoaChange" disabled placeholder="请选择试投结果" style="width:100%;" size="small">
                                <el-option key="0" label="OK" value="0" />
                                <el-option key="1" label="NG" value="1" />
                                <el-option key="NA" label="NA" value="2" />
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item :label="$t('inspectionManagement.samplingType')" prop="samplingType">
                            <el-input :value="formatCE_STRATEGY(viewModel.samplingType)" disabled clearable size="small" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item :label="'供应商名称'" prop="supplierName">
                            <el-input v-model="viewModel.supplierName" disabled clearable size="small" />
                        </el-form-item>
                    </el-col><el-col :span="6">
                        <el-form-item :label="'供应商名称（修改后）'" prop="supplierAliasName">
                            <el-input v-model="viewModel.supplierAliasName" disabled clearable size="small" />
                        </el-form-item>
                    </el-col>
                    <!--<el-col :span="6" v-if="viewModel.dataSource==='进料'">
                        <el-form-item :label="$t('inspectionManagement.isTestMaterial')" prop="experimentMaterial">
                            <span class="labelN" v-if="viewModel.experimentMaterial !== '1'">{{$t('public.no')}}</span>
                            <span class="labelY" v-if="viewModel.experimentMaterial === '1'">{{$t('public.yes')}}</span>
                        </el-form-item>
                    </el-col>-->
                </el-row>

            </el-form>
        </el-card>
        <el-card class="box-card" style="margin-top:24px;" id="fullscreen" v-if="viewModel.exempted !== '1'&&viewModel.experimentMaterial!== '1'">
            <div class="app-container">
                <div class="container-header">
                    <div class="hign-line"></div>
                    <div class="header-left">
                        {{$t('inventoryManagement.inspectionInfo')}}
                        <el-button  size="mini" @click="handleImport" icon="el-icon-upload" style="height: 30px;margin-left:10px ;" >
                            {{$t('public.import')}}
                        </el-button>

                    </div>
                    <div class="header-right">
                        <i class="s-icon" :class="{
            'el-icon-full-screen': !fullscreen,
            'el-icon-copy-document': fullscreen,
          }" @click="changeFull"></i>
                    </div>

                </div>
                <!-- <el-row :gutter="10" class="mb8">
                    <el-col :span="1.5">

                         <el-button type="primary" icon="el-icon-search" size="mini" @click="handleSelectTemplate">{{$t('inspectionManagement.selectCopy')}}</el-button>
                    </el-col>
                </el-row> -->
                <div class="container-table">
                    <el-table :row-class-name="tableRowClassName" v-loading="loading" ref="itemTable" :data="typeList" @selection-change="handleSelectionChange" :key="typeListKey" :height="tableHeight" border>
                        <!-- <el-table-column type="selection" width="55" align="center" /> -->
                        <el-table-column type="selection" width="55" align="center" />
                        <el-table-column :label="$t('inventoryManagement.code')" align="left" prop="projectCode" :show-overflow-tooltip="true" />
                        <el-table-column :label="$t('inventoryManagement.specialCharacteristics')" align="left" prop="symbol" minWidth="80" :show-overflow-tooltip="true" />
                        <el-table-column :label="$t('inventoryManagement.inspectionItems')" align="left" prop="projectName" minWidth="110" />
                        <el-table-column :label="$t('inventoryManagement.inspectionTypeUnit')" minWidth="100" prop="unitName" align="left" :show-overflow-tooltip="true" />
                        <el-table-column :label="$t('inventoryManagement.targetValue')" align="left" prop="targetValue" :show-overflow-tooltip="true" />
                        <el-table-column :label="$t('inventoryManagement.lowerValue')" minWidth="80" align="left" prop="lowerLimit" :show-overflow-tooltip="true" />
                        <el-table-column :label="$t('inventoryManagement.upperValue')" minWidth="80" align="center" prop="upperLimit" />
                        <el-table-column :label="$t('inventoryManagement.resultValue')" align="left" prop="resultValue" :show-overflow-tooltip="true" />

                        <el-table-column :label="$t('inventoryManagement.inspectionType')" minWidth="80" align="left" prop="checkoutTypeCopy" />
                        <!--                        <el-table-column :label="$t('inventoryManagement.gapValue')" align="left" prop="gap" :show-overflow-tooltip="true" />-->
                        <el-table-column :label="$t('inspectionManagement.aroundFrequency')" minWidth="110" align="left" prop="itemFrequency" :show-overflow-tooltip="true" />
                        <el-table-column :label="$t('inventoryManagement.frequencyValue')" align="left" prop="itemFrequencyValue" :show-overflow-tooltip="true" />
                        <el-table-column :label="$t('inspectionManagement.SampleSizeCode')" align="left" prop="sampleCode" minWidth="120" :show-overflow-tooltip="true" />
                        <el-table-column :label="$t('inspectionManagement.ReceivedQuantity')" align="left" prop="samAc" minWidth="120" :show-overflow-tooltip="true" />
                        <el-table-column :label="$t('inspectionManagement.RejectionNumber')" align="left" prop="samRe" minWidth="120" :show-overflow-tooltip="true" />
                        <!-- <el-table-column label="SN编号" align="left" prop="snNums" minWidth="120" :show-overflow-tooltip="true" /> -->
                        <el-table-column :label="$t('inventoryManagement.inspector')" align="left" prop="inspectorName" minWidth="120" :show-overflow-tooltip="true" />

                        <el-table-column :label="$t('inventoryManagement.samplingScheme')" align="left" prop="samplingOne" minWidth="120" :show-overflow-tooltip="true" />
                        <el-table-column :label="$t('inventoryManagement.samplingOptions')" align="left" prop="samplingTwo" minWidth="120">
                            <template slot-scope="scope">
                                <template v-if="scope.row.samplingOne == 'GB/T2828.1-2012'">
                                <span >{{formatCE_CLASS(scope.row.samplingTwo)}}</span> <span>{{scope.row.samplingThree}}</span>
                                </template>
                                <span v-else-if="scope.row.samplingOne == '百分比'">{{scope.row.samplingTwo}}%</span>
                                <span v-else-if="scope.row.samplingOne == 'C=0'">{{scope.row.samplingThree}}</span>
                                <span v-else-if="scope.row.samplingOne == '固定抽样'">{{scope.row.samplingTwo}}</span>
                                <!-- 自定义抽样 -->
                                <span v-else>{{scope.row.samplingThree}}</span>
                            </template>
                        </el-table-column>
                        <el-table-column :label="$t('inventoryManagement.defectLevel')" align="left" prop="flawLevel" :show-overflow-tooltip="true" />
                        <el-table-column :label="$t('inventoryManagement.samplingQuantity')" align="left" prop="samplingAmount" :show-overflow-tooltip="true" />
                        <el-table-column :label="$t('formValidation.qualifiedQuantity')" align="left" prop="qualifiedNum" :show-overflow-tooltip="true" />
                        <el-table-column :label="$t('inventoryManagement.testMethod')" align="left" prop="detectionOne" :minWidth="150" :show-overflow-tooltip="true">
                            <template slot-scope="scope">
                                <span>{{scope.row.detectionOne}}</span> <span>{{scope.row.detectionTwo}}</span>
                            </template>
                        </el-table-column>
                        <el-table-column :label="$t('inventoryManagement.decimalPlaces')" align="left" prop="decimalPlace" :show-overflow-tooltip="true" />
                        <el-table-column :label="$t('inspectionManagement.remark')" align="left" prop="classRemark" :minWidth="150" :show-overflow-tooltip="true" />
                        <!-- 周检验 
                        "passFlag":"1",// 1：标识已检
                        "seriesFlag":"1",// 1：是否需要连续检验10批
                        "passNumber":"6"//连续检验合格批数
                        -->
                        <el-table-column label="周期检验结果" align="center" fixed="right">
                             
                            <template slot-scope="scope">
                                <div>
                                    <p v-if="scope.row.passFlag==1" style="background-color: green;color: #fff;">已检</p>
                                    <p v-if="scope.row.seriesFlag==1" style="background-color: red;color: #fff;">
                                        已连续合格{{scope.row.passNumber}}批
                                    </p>
                                </div>
                    
                            </template>
                        
                        </el-table-column>
                        <!-- <el-table-column :label="$t('inventoryManagement.inspectionValue')" align="center">
                            <el-table-column :label="item" v-for="(item,index) in tableHeader" :key="index" minWidth="160" align="center" prop="gap">
                                <template slot-scope="scope">
                                    <el-input-number @change="(e)=>valueChange(e,scope,index)" v-if="scope.row.checkoutType!=='布尔型'&&index<parseInt(scope.row.samplingAmount)" :controls="false" v-model="scope.row['value'+index]" clearable size="small" />
                                    <el-select v-if="scope.row.checkoutType==='布尔型'&&index===0" @change="(e)=>changeCheckoutValue(e,scope,index)" v-model="typeList[scope.$index]['value'+index]" style="width:100%;" clearable size="small">
                                        <el-option key="0" label="OK" value="OK" />
                                        <el-option key="1" label="NG" value="NG" />
                                    </el-select>
                                </template>
                            </el-table-column>
                        </el-table-column>

                        <el-table-column :label="$t('defectIncoming.smallDefect')" align="left" width="140" prop="inspectorName" :show-overflow-tooltip="true">
                            <template slot-scope="scope">
                                <el-autocomplete style="width:100%" size="small" popper-class="my-autocomplete" v-model="scope.row.flawProjectName" v-if="scope.row.checkoutResult===0" :fetch-suggestions="minFlawRemoteMethod" placeholder="请输入内容" @select="(e)=>handleMinFlawSelect(e,scope)">
                                    <i class="el-icon-search el-input__icon" slot="suffix">
                                    </i>
                                    <template slot-scope="{ item }">
                                        {{ item.minFlawName }}
                                    </template>
                                </el-autocomplete>
                            </template>
                        </el-table-column>
                        <el-table-column :label="$t('inventoryManagement.inspector')" align="left" prop="inspectorName" :show-overflow-tooltip="true" /> -->

                        <!-- <el-table-column :label="$t('public.upload')" prop="file" width="160" align="center" :show-overflow-tooltip="true">
                            <template slot-scope="scope">
                                <file-upload :ref="'projectItemFiles'+scope.$index" :isShowTip="false" :bizId="scope.row.id" @change="(fileList)=>fileChange(fileList,scope.$index)"></file-upload>
                            </template>
                        </el-table-column> -->
                        <el-table-column :label="$t('inspectionManagement.checkoutResult')" align="center" fixed="right" width="100">
                            <template slot-scope="scope">
                                <span v-if="scope.row.checkoutResult=='0'" class="result-tag-red">{{$t('inventoryManagement.unqualified')}}</span>
                                <span v-else-if="scope.row.checkoutResult=='1'" class="result-tag-green">{{$t('inventoryManagement.qualified')}}</span>
                                <span v-else-if="scope.row.checkoutResult=='2'" class="result-tag-yellow">NA</span>
                                <span v-else class="labelN">{{$t('inventoryManagement.Notentered')}}</span>
                            </template>
                        </el-table-column>

                        <el-table-column v-if="isEdit" :label="$t('public.opera')" fixed="right" align="left" width="100">
                            <template slot-scope="scope">
                                <div class="action-wrap">
                                    <table-body-btn type="edit" :name="$t('public.edit')" @click.native="handleEdit(scope,true,false)" />
                                    <table-body-btn type="view" name='获取数据' @click.native="getData(scope)" />
                                    
                                </div>
                            </template>
                        </el-table-column>
                    </el-table>
                </div>
            </div>
            <el-drawer :with-header="false" :visible.sync="drawer" :title="$t('inspectionManagement.editInspectionItems')" size="50%" :direction="direction" :before-close="handleClose">
                <div class="app-container" style="max-height:calc(100vh - 160px);overflow-y:auto">
                    <div class="container-header">
                        <div class="header-left">
                            {{$t('inspectionManagement.editInspectionItems')}}
                        </div>
                    </div>
                    <el-form :model="currentItem" ref="currentQueryForm" v-show="showSearch" :rules="queryFormRules" label-width="88px">
                        <el-row :gutter="24" class="mb8">
                            <el-col :span="8">
                                <el-form-item :label="$t('inventoryManagement.inspectionItems')" prop="projectName">
                                    <el-input v-model="currentItem.projectName" readonly clearable size="small" @keyup.enter.native="handleQuery" />
                                </el-form-item>
                            </el-col>
                            <el-col :span="8">
                                <el-form-item :label="$t('inventoryManagement.inspectionType')" prop="checkoutTypeCopy">
                                    <el-input v-model="currentItem.checkoutTypeCopy" readonly clearable size="small" @keyup.enter.native="handleQuery" />
                                </el-form-item>
                            </el-col>
                            <el-col :span="8">
                                <el-form-item :label="$t('inventoryManagement.samplingQuantity')" prop="samplingAmount">
                                    <el-input v-model="currentItem.samplingAmount" readonly clearable size="small" />
                                </el-form-item>
                            </el-col>
                            <el-col :span="8" v-if="(currentItem.samplingOne==='GB/T2828.1-2012')&&currentItem.checkoutType==='布尔型'">
                                <el-form-item :label="$t('inspectionManagement.SampleSizeCode')" prop="sampleCode">
                                    <el-input v-model="currentItem.sampleCode" readonly clearable size="small" />
                                </el-form-item>
                            </el-col>
                            <el-col :span="8" v-if="!((currentItem.samplingOne==='GB/T2828.1-2012'||currentItem.samplingOne==='GB/T2828.2-2008')&&currentItem.checkoutType==='布尔型')">
                                <el-form-item :label="$t('inventoryManagement.lowerValue')" prop="lowerLimit">
                                    <el-input v-model="currentItem.lowerLimitCopy" readonly clearable size="small">
                                        <template slot="append">
                                            {{currentItem.lowerLimitContains==='0'?$t('inventoryManagement.doesnotcontain'):$t('inventoryManagement.contain')}}
                                        </template>
                                    </el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="8" v-if="!((currentItem.samplingOne==='GB/T2828.1-2012'||currentItem.samplingOne==='GB/T2828.2-2008')&&currentItem.checkoutType==='布尔型')">
                                <el-form-item :label="$t('inventoryManagement.upperValue')" prop="upperLimit">
                                    <el-input v-model="currentItem.upperLimitCopy" readonly clearable size="small">
                                        <template slot="append">
                                            {{currentItem.upperLimitContains==='0'?$t('inventoryManagement.doesnotcontain'):$t('inventoryManagement.contain')}}
                                        </template>
                                    </el-input>
                                </el-form-item>
                            </el-col>
                            <template v-if="currentItem.samplingOne==='GB/T2828.1-2012'||currentItem.samplingOne==='GB/T2828.2-2008'">
                                <el-col :span="8" >
                                <el-form-item :label="$t('inspectionManagement.ReceivedQuantity')" prop="samAc">
                                    <el-input v-model="currentItem.samAc" readonly clearable size="small" />
                                </el-form-item>
                            </el-col>
                            <el-col :span="8" >
                                <el-form-item :label="$t('inspectionManagement.RejectionNumber')" prop="samRe">
                                    <el-input v-model="currentItem.samRe" readonly clearable size="small" />
                                </el-form-item>
                            </el-col>
                            </template>

                            <!--                            <el-col :span="8" v-else>
                                <el-form-item :label="$t('inventoryManagement.gapValue')" prop="gap">
                                    <el-input v-model="currentItem.gap" readonly clearable size="small" />
                                </el-form-item>
                            </el-col>-->

                            <el-col :span="8">
                                <el-form-item :label="$t('inventoryManagement.inspector')" prop="inspectorName">
                                    <el-input v-model="currentItem.inspectorName" readonly clearable size="small" />
                                    <!-- <select-user-dialog v-model="currentItem.inspectorName" :placeholder="$t('public.select_holder',{select_holder: $t('inventoryManagement.inspector')})" :titleName="$t('defectIncoming.selectMan')" @callback="(id)=>userDataCallback(id)" /> -->
                                </el-form-item>
                            </el-col>
                            <el-col :span="8" v-if="currentItem.checkoutType!=='布尔型'">
                                <el-form-item :label="$t('inventoryManagement.targetValue')" prop="targetValue">
                                    <el-input v-model="currentItem.targetValueCopy" readonly size="small" />
                                </el-form-item>
                            </el-col>
                            <el-col :span="24" v-if="currentItem.checkoutType==='布尔型'">
                                <el-form-item :label="$t('inventoryManagement.targetValue')" prop="targetValue">
                                    <el-input v-model="currentItem.targetValue" resize="none" readonly type="textarea" :rows="3" size="small" />
                                </el-form-item>
                            </el-col>
                            <template v-if="currentItem.checkoutType==='数值'">
                            <el-col :span="8" >
                                <el-form-item :label="$t('outlier.min')" prop="minimum">
                                    <el-input v-model="currentItem.minimum" readonly clearable size="small" />
                                </el-form-item>
                            </el-col>
                            <el-col :span="8" >
                                <el-form-item :label="$t('outlier.max')" prop="maximum">
                                    <el-input v-model="currentItem.maximum" readonly clearable size="small" />
                                </el-form-item>
                            </el-col>
                            <el-col :span="8" >
                                <el-form-item :label="$t('outlier.averageValue')" prop="meanValue">
                                    <el-input v-model="currentItem.meanValue" readonly clearable size="small" />
                                </el-form-item>
                            </el-col>
                            <el-col :span="8" >
                                <el-form-item :label="$t('outlier.range')" prop="rangeValue">
                                    <el-input v-model="currentItem.rangeValue" readonly clearable size="small" />
                                </el-form-item>
                            </el-col>
                            <el-col :span="8">
                                <el-form-item :label="$t('inventoryManagement.singlesamplejudgment')" label-width="80px">
                                    <el-select v-model="currentItem.singleSample" style="width:100%;" :disabled="currentItem.dataType == 1 ? true : false" size="small" @change="changesingleSample">
                                        <el-option :label="$t('outlier.averageValue')" :value="'1'" />
                                        <el-option :label="$t('outlier.min') + '-' + $t('outlier.max')" :value="'2'" />
                                    </el-select>
                                </el-form-item>
                            </el-col>

                            <!-- <el-col :span="8" >
                                <el-form-item :label="$t('inventoryManagement.targetValue')" prop="targetValue">
                                    <el-input v-model="currentItem.targetValue" :readonly="currentItem.dataType == 1 ? true : false"  size="small"
                                    @input="(e)=>targetValueChange(e)"/>
                                </el-form-item>
                            </el-col> -->
                            <el-col :span="8" >
                                <el-form-item :label="$t('inspectionManagement.lowerTolerance')" prop="rangeValue">
                                    <el-input v-model="currentItem.lwTolerance" :readonly="currentItem.dataType == 1 ? true : false"  clearable size="small"
                                    @input="targetValueChange"/>
                                </el-form-item>
                            </el-col>
                            <el-col :span="8" >
                                <el-form-item :label="$t('inspectionManagement.upperTolerance')"  prop="rangeValue">
                                    <el-input v-model="currentItem.upTolerance" :readonly="currentItem.dataType == 1 ? true : false" clearable size="small"
                                    @input="targetValueChange"/>
                                </el-form-item>
                            </el-col>
                            <!-- <el-col :span="8">
                                <el-form-item :label="$t('inventoryManagement.lowerValue')" prop="lowerLimit">
                                    <el-input v-model="currentItem.lowerLimit"   clearable size="small" />
                                </el-form-item>
                            </el-col>
                            <el-col :span="8" >
                                <el-form-item :label="$t('inventoryManagement.upperValue')" prop="upperLimit">
                                    <el-input v-model="currentItem.upperLimit"   clearable size="small" />
                                </el-form-item>
                            </el-col> -->
                            </template>
                            <el-col :span="8">
                                <el-form-item :label="$t('formValidation.qualifiedQuantity')" label-width="80px">
                                    <el-input v-model="currentItem.qualifiedNum" :readonly="currentItem.dataType == 1 ? true : false" clearable size="small" @input="acceptChange2" />
                                </el-form-item>
                            </el-col>
                            <el-col :span='24' v-if="currentItem.checkoutTypeCopy == '计量' && currentItem.samplingOne !='C=0'">
                                <el-button type="primary" @click="Cdv" :disabled='differenceRepairSheet[currentItem.id]' size="mini">{{$t('inventoryManagement.Compensationdifferencevalue')}}</el-button>
                            </el-col>
                            <el-col :span="24">
                                <el-form-item label=" ">
                                    <!-- start -->
                                    <template v-if="currentItem.checkoutType==='数值'">
                                        <el-row  :gutter="24" class="mb8" v-for="(itemT,indexT) in displayedCheckoutList" :key="indexT">
                                            <el-form ref="tableFormRef" :model="itemT" :rules="tableFormRule" inline-message>
                                            <el-col :span="8">
                                                <el-form-item :label="$t('specimen.sampleCode')" label-width="80px" prop="sampleCode">
                                                    <el-input size="small" v-model="itemT.sampleCode" :readonly="currentItem.dataType == 1 ? true : false"  placeholder="请输入样本编号"></el-input>
                                                </el-form-item>
                                            </el-col>

                                            <el-col :span="18">
                                                <el-table border stripe :data="itemT.checkoutItemList" max-height="300">
                                                    <el-table-column type="index" width="55" align="center"></el-table-column>
                                                    <el-table-column :label="$t('inventoryManagement.inspectionValue')" align="left" prop="checkoutValue" :render-header="remarkRenderHeader">
                                                        <template slot-scope="scope">
                                                            <el-form-item :prop="'checkoutItemList.'+scope.$index+'.checkoutValue'"  :rules="tableFormRule.checkoutValue">

                                                        <!-- <el-form-item :prop="'flawList.' + scope.$index + '.minFlawName'" :rules="minFlawRules(scope.row,scope.$index)"> -->
                                                            <el-input :readonly="currentItem.dataType == 1 ? true : false" :ref="'input.'+indexT+'.'+scope.$index" v-model="scope.row.checkoutValue" :class="'input'+scope.$index"  clearable size="small"
                                                             @input="(e)=>acceptChangeItem(e,scope,itemT,indexT)" placeholder="请输入" @keyup.enter.native="focusNextInput(scope.$index,itemT,indexT)"/>
                                                            </el-form-item>
                                                        </template>
                                                    </el-table-column>
                                                    <!-- <el-table-column :label="$t('inspectionManagement.checkoutResult')" align="left" prop="resultValue"></el-table-column> -->
                                                    <el-table-column :label="$t('inventoryManagement.judgmentResult')" align="left" prop="result">
                                                        <template slot-scope="scope">
                                                        <div v-show="scope.row.resultValue =='0' || scope.row.resultValue">
                                                            <span v-if="scope.row.result=='0'" class="result-tag-red">{{ $t('inventoryManagement.unqualified') }}</span>
                                                            <span v-if="scope.row.result=='1'" class="result-tag-green">{{ $t('inventoryManagement.qualified') }}</span>
                                                            <span v-if="scope.row.result=='2'" class="result-tag-yellow">NA</span>
                                                        </div>
                                                        </template>
                                                    </el-table-column>
                                                    <el-table-column :label="$t('public.opera')" fixed="right" align="center" width="60">
                                                        <template slot-scope="scope">
                                                            <div class="action-wrap">
                                                                <table-body-btn type="gwdelete" :name="$t('public.delete')" @click.native="handleCheckoutItemDel(scope,itemT.checkoutItemList)" />
                                                            </div>
                                                        </template>
                                                    </el-table-column>
                                                </el-table>
                                            </el-col>

                                            <el-col :span="6">
                                                <el-input size="small" v-model="itemT.addNum" :readonly="currentItem.dataType == 1 ? true : false"  placeholder="再添加检验项个数"></el-input>
                                                <el-button icon="el-icon-plus" circle size="mini" @click="handleAddCheck(itemT)" />
                                                <span class="projectAddBtn" @click="handleAddCheck(itemT,itemT.addNum)">{{$t('btn.tianjia')}} {{itemT.addNum || "1"}} {{ $t('formValidation.checkItem') }}</span>

                                            </el-col>
                                            <!-- v-if="currentItem.singleSample==1" -->
                                            <el-col :span="16" >
                                                <div>
                                                    <span style="padding-left:10px;" v-if="currentItem.singleSample==1"> {{ $t('outlier.averageValue') }}:{{ itemT.singleValue }}</span>
                                                    <span style="padding-left:10px;"> {{ $t('inventoryManagement.singlesamplejudgment') }}：</span>
                                                    <span v-if="itemT.singleResult=='0'" class="result-tag-red">{{ $t('inventoryManagement.unqualified') }}</span>
                                                    <span v-if="itemT.singleResult=='1'" class="result-tag-green">{{ $t('inventoryManagement.qualified') }}</span>
                                                    <!-- <span v-if="itemT.singleResult==''" class="result-tag-yellow">NA</span> -->
                                                </div>
                                            </el-col>
                                            </el-form>
                                        </el-row>
                                      <!-- 滚动到底部加载更多按钮 -->
                                      <div ref="loadMore" v-if="hasMore" class="load-more-container">
                                        <button v-if="!loadMoreLoading" @click="loadMore">加载更多</button>
                                        <button v-else>加载中...</button><!--v-else-->
                                      </div>
                                    </template>
                                    <!-- end -->
                                    <el-table border stripe v-loading="loading" :data="currentItem.inspectionValues" max-height="300" v-else>
                                        <el-table-column type="index" width="55" align="center"></el-table-column>
                                        <el-table-column :label="$t('inspectionManagement.QualifiedQuantity')" align="left" prop="inspectionValue" v-if="(currentItem.samplingOne==='GB/T2828.1-2012'||currentItem.samplingOne==='GB/T2828.2-2008')&&currentItem.checkoutType==='布尔型'">
                                            <template slot-scope="scope">
                                                <div>
                                                    <el-input v-model="scope.row.inspectionValue" :readonly="currentItem.dataType == 1 ? true : false" :class="'input'+scope.$index" type="number" @input="(e)=>acceptChange(e,scope)" clearable size="small" />
                                                </div>

                                            </template>
                                        </el-table-column>
                                        <el-table-column :label="$t('inventoryManagement.inspectionValue')" align="left" prop="inspectionValue" v-else>
                                            <template slot-scope="scope">
                                                <div>
                                                    <el-select :disabled="currentItem.dataType == 1 ? true : false" transfer :popper-append-to-body="false" v-if="currentItem.checkoutType==='布尔型'" @change="(e)=>changeCheckoutValue(e,scope)" v-model="scope.row.inspectionValue" style="width:100%;" clearable size="small">
                                                        <el-option key="0" label="OK" value="OK" />
                                                        <el-option key="1" label="NG" value="NG" />
                                                        <el-option key="2" label="NA" value="NA" />
                                                    </el-select>
                                                    <el-input :readonly="currentItem.dataType == 1 ? true : false" v-else v-model="scope.row.inspectionValue" :class="'input'+scope.$index" type="number" @input="(e)=>valueChange(e,scope)" @keyup.enter.native="nextInput('input'+(scope.$index+1),scope.$index)" clearable size="small" />
                                                </div>

                                            </template>
                                        </el-table-column>

                                        <el-table-column :label="((currentItem.samplingOne==='GB/T2828.1-2012'||currentItem.samplingOne==='GB/T2828.2-2008')&&currentItem.checkoutType==='布尔型')?$t('transferRules.jyCheckNum'):$t('inventoryManagement.resultValue')" align="left" prop="resultValue" :show-overflow-tooltip="true" />
                                        <el-table-column :label="$t('inspectionManagement.judgmentResult')" align="left" :show-overflow-tooltip="true">
                                            <template slot-scope="scope">
                                                <div v-show="scope.row.resultValue == '0' || scope.row.resultValue">
                                                    <span v-if="scope.row.resultType=='0'" class="result-tag-red">{{$t('inventoryManagement.unqualified')}}</span>
                                                    <span v-if="scope.row.resultType=='1'" class="result-tag-green">{{$t('inventoryManagement.qualified')}}</span>
                                                    <span v-if="scope.row.resultType=='2'" class="result-tag-yellow">NA</span>
                                                </div>
                                            </template>
                                        </el-table-column>
                                    </el-table>
                                </el-form-item>
                            </el-col>
                            <el-col :span="24">
                                <el-form-item :label="$t('defectIncoming.inspectResults')" v-show="comprehensiveResults!==''">
                                    <span :class="comprehensiveResults==='不合格'?'result-tag-red':comprehensiveResults==='NA'?'result-tag-yellow':'result-tag-green'">{{comprehensiveResults}}</span>
                                </el-form-item>
                            </el-col>

                            <el-col :span="24" v-if="comprehensiveResults==='不合格'">
                                <el-form-item label=" ">
                                    <el-button type="primary" @click="addFlaw" icon="el-icon-check" size="mini">新增缺陷</el-button>
                                </el-form-item>

                                <el-form-item label="缺陷">
                                    <el-form ref="formTable" :model="currentItem">
                                        <el-table border stripe v-loading="loading" :data="currentItem.flawList" max-height="300">
                                            <el-table-column type="index" width="55" align="center"></el-table-column>
                                            <el-table-column label="大缺陷名称" align="left" prop="minFlawName">
                                                <template slot-scope="scope">
                                                    <el-select size="small"
                                                        :disabled="currentItem.dataType == 1 ? true : false"
                                                        v-model="scope.row.maxFlawName"
                                                        filterable
                                                        remote
                                                        clearable
                                                        reserve-keyword
                                                        automatic-dropdown
                                                        placeholder="请输入"
                                                        value-key="id"
                                                        autocomplete
                                                        :remote-method="maxFlawNameRemoteFN"
                                                        :loading="maxLoading"
                                                        @change="(e)=>changeMaxFlaw(e,scope)"
                                                        @clear="maxFlawNameRemoteFN('')"
                                                        @focus="maxFlawNameOptions.length==0? maxFlawNameRemoteFN(scope.row.maxFlawName):()=>void 0">
                                                        <el-option  v-for="item in maxFlawNameOptions"  :key="item.id"  :label="item.maxFlawName"  :value="item.maxFlawName" />
                                                    </el-select>
                                                    <!-- <div v-if="false">
                                                        <el-autocomplete style="width:100%" size="small" popper-class="my-autocomplete" v-model="scope.row.maxFlawName" :fetch-suggestions="maxRemoteMethod" placeholder="请输入" @select="(e)=>changeMaxFlaw(e,scope)">
                                                            <i class="el-icon-search el-input__icon" slot="suffix">
                                                            </i>
                                                            <template slot-scope="{ item }">
                                                                {{ item.maxFlawName }}
                                                            </template>
                                                        </el-autocomplete>
                                                    </div> -->

                                                </template>
                                            </el-table-column>
                                            <el-table-column label="小缺陷名称" align="left" prop="minFlawName" :render-header="remarkRenderHeader">
                                                <template slot-scope="scope">
                                                    <div>
                                                        <el-form-item :prop="'flawList.' + scope.$index + '.minFlawName'" :rules="minFlawRules(scope.row,scope.$index)">
                                                            <el-select size="small"
                                                                :disabled="currentItem.dataType == 1 ? true : false"
                                                                v-model="scope.row.minFlawName"
                                                                filterable
                                                                remote
                                                                clearable
                                                                reserve-keyword
                                                                automatic-dropdown
                                                                placeholder="请输入"
                                                                :remote-method="(e)=>minFlawNameRemoteFN(e,scope.row)"
                                                                :loading="minLoading"
                                                                @change="(e)=>changeFlaw(e,scope)"
                                                                @clear="minFlawNameRemoteFN('',scope.row)"
                                                                @focus="minFlawNameRemoteFN(scope.row.minFlawName,scope.row)">
                                                                <el-option  v-for="item in minFlawNameOptions"  :key="item.id"  :label="item.minFlawName"  :value="item.minFlawName" />
                                                            </el-select>
                                                            <!-- <el-autocomplete v-if="false" style="width:100%" size="small" popper-class="my-autocomplete" v-model="scope.row.minFlawName" :fetch-suggestions="(val,cb)=>unitRemoteMethod(val,cb,scope.row.maxFlawId)" placeholder="请输入" @select="(e)=>changeFlaw(e,scope)">
                                                                <i class="el-icon-search el-input__icon" slot="suffix">
                                                                </i>
                                                                <template slot-scope="{ item }">
                                                                    {{ item.minFlawName }}
                                                                </template>
                                                            </el-autocomplete> -->
                                                        </el-form-item>

                                                    </div>

                                                </template>
                                            </el-table-column>
                                            <el-table-column label="缺陷数量" align="left" prop="minFlawNr" width="100" :render-header="remarkRenderHeader">
                                                <template slot-scope="scope">
                                                    <el-form-item :prop="'flawList.' + scope.$index + '.minFlawNr'" :rules="minFlawNrRules(scope.row,scope.$index)">
                                                        <el-input :readonly="currentItem.dataType == 1 ? true : false" v-model.number="scope.row.minFlawNr" clearable size="mini" @onkeyup="scope.row.minFlawNr=(/[.]/.test(scope.row.minFlawNr)?'1':parseInt(scope.row.minFlawNr))" />
                                                    </el-form-item>

                                                </template>
                                            </el-table-column>
                                            <el-table-column label="操作" align="left" prop="minFlawNr" width="80">
                                                <template slot-scope="scope">
                                                    <table-body-btn type="gwdelete" @click.native="deleteFlaw(scope)" />

                                                </template>
                                            </el-table-column>
                                        </el-table>
                                    </el-form>

                                </el-form-item>
                            </el-col>
                            <el-col :span="24">
                                <el-form-item :label="$t('public.upload')">
                                    <file-upload :disabled="currentItem.dataType == 1 ? true : false" ref="projectItemFiles" bizType='UPLOAD_FILE_ITEM' :otherList="itemFileList" :bizId="rowId" @change="(fileList)=>itemFileChange(fileList)"></file-upload>
                                </el-form-item>
                            </el-col>
                            <el-col :span="24">
                                <el-form-item :label="$t('inspectionManagement.remark')">
                                    <el-input :readonly="currentItem.dataType == 1 ? true : false" v-model="currentItem.classRemark" resize="none" type="textarea" :rows="3" size="small" />
                                </el-form-item>
                            </el-col>
                        </el-row>

                    </el-form>
                </div>
                <div class="drawer-footer">
                    <el-button icon="el-icon-close" size="mini" @click="drawerClose" class="drawer-close">{{$t('public.cancel')}}</el-button>
                    <!-- <el-button icon="el-icon-refresh" class="resectBtn drawer-close"  size="mini"  >{{$t('public.reset')}}</el-button> -->
                    <el-button type="primary" v-if='!applicationStatus && currentItem.dataType != 1' @click="drawerSubmit" icon="el-icon-check" size="mini">{{$t('public.define')}}</el-button>
                    <el-button type="primary" v-if='applicationStatus' @click="application" icon="el-icon-check" size="mini">应用</el-button>
                </div>
            </el-drawer>
            <copyInspectDataDialog :visible.sync="templateVisible" :viewModel="viewModel" v-if="templateVisible" @callback="(row)=>updateInspect(row)" />
        </el-card>
        <!-- 关联条码表 -->
        <el-button @click="showglb" style="margin-top: 14px;">{{$t('inspectionManage.barcode')}}</el-button>
        <el-button @click="showImortRlatedBarcod" style="margin-top: 14px;">{{$t('inspectionManage.importBarcode')}}</el-button>
        <el-button @click="showContainerNumber" style="margin-top: 14px;">{{$t('inspectionManage.viewContainerNumber')}}</el-button>
        <el-card class="box-card" style="margin-top:14px">
            <div class="container-header">
                <div class="hign-line"></div>
                <div class="header-left">
                    缺陷判定
                </div>
            </div>
            <div class="container-table">
                    <el-table :row-class-name="tableRowClassNameDefect" ref="flowTable" :data="inspectionFlawList" :border='true'>
                        <el-table-column :label="'项目类型'" prop="projectType" :show-overflow-tooltip="true" />
                        <!-- <el-table-column :label="'缺陷类型'" prop="flawLevel" minWidth="80" :show-overflow-tooltip="true" /> -->
                        <!-- <el-table-column :label="'抽样方案'" prop="samplingOne" minWidth="110" /> -->
                        <el-table-column :label="'抽样方案'" minWidth="180" :show-overflow-tooltip="true">
                            <template slot-scope="scope">
                                <span>{{ scope.row.samplingOne }}</span><span :style='{marginLeft:"12px"}'>{{scope.row.samplingTwo}}</span>
                            </template>
                        </el-table-column>
                        <el-table-column :label="'CR允收'" prop="samplingThreeCr" minWidth="90" />
                        <el-table-column :label="'AC/RE'" minWidth="90" :show-overflow-tooltip="true">
                            <template slot-scope="scope" v-if='scope.row.samReCr'>
                                <span>{{ scope.row.samAcCr }}</span><span>/</span><span>{{scope.row.samReCr}}</span>
                            </template>
                        </el-table-column>
                        <el-table-column :label="'MA允收'" prop="samplingThreeMa" minWidth="90" />
                        <el-table-column :label="'AC/RE'" minWidth="90" :show-overflow-tooltip="true">
                            <template slot-scope="scope" v-if='scope.row.samReMa'>
                                <span>{{ scope.row.samAcMa }}</span><span>/</span><span>{{scope.row.samReMa}}</span>
                            </template>
                        </el-table-column>
                        <el-table-column :label="'MI允收'" prop="samplingThreeMi" minWidth="90" />
                        <el-table-column :label="'AC/RE'" minWidth="90" :show-overflow-tooltip="true">
                            <template slot-scope="scope" v-if='scope.row.samReMi'>
                                <span>{{ scope.row.samAcMi }}</span><span>/</span><span>{{scope.row.samReMi}}</span>
                            </template>
                        </el-table-column>
                        <!-- <el-table-column :label="'检验水平'" minWidth="100" prop="samplingTwo" :show-overflow-tooltip="true" /> -->
                        <!-- <el-table-column :label="'检验等级'" prop="samplingThree" :show-overflow-tooltip="true" /> -->
                        <!-- <el-table-column :label="'设定标准'" minWidth="120" :show-overflow-tooltip="true">
                            <template slot-scope="scope">
                                <span>Ac：</span><span>{{scope.row.samAc}}</span><span>Re：</span><span>{{scope.row.samRe}}</span>
                            </template>
                        </el-table-column> -->
                        <!-- <el-table-column :label="'统计结果值'" minWidth="120" :show-overflow-tooltip="true">
                            <template slot-scope="scope">
                                <span>Ac：</span><span>{{Obj[scope.row.id].samAcCount}}</span><span>Re：</span><span>{{Obj[scope.row.id].samReCount}}</span>
                            </template>
                        </el-table-column> -->
                        <el-table-column :label="'CR'" minWidth="120" :show-overflow-tooltip="true">
                            <template slot-scope="scope">
                                <span :style="{color:Obj[scope.row.id].samReCountCr >= scope.row.samReCr ? 'red' : '' }">{{Obj[scope.row.id].samReCountCr}}</span>
                            </template>
                        </el-table-column>
                        <el-table-column :label="'MA'" minWidth="120" :show-overflow-tooltip="true">
                            <template slot-scope="scope">
                                <span :style="{color:Obj[scope.row.id].samReCountMa >= scope.row.samReMa ? 'red' : '' }">{{Obj[scope.row.id].samReCountMa}}</span>
                            </template>
                        </el-table-column>
                        <el-table-column :label="'MI'" minWidth="120" :show-overflow-tooltip="true">
                            <template slot-scope="scope">
                                <span :style="{color:Obj[scope.row.id].samReCountMi >= scope.row.samReMi ? 'red' : '' }">{{Obj[scope.row.id].samReCountMi}}</span>
                            </template>
                        </el-table-column>
                        <el-table-column :label="'判定结果'" minWidth="120" :show-overflow-tooltip="true">
                            <template slot-scope="scope">
                                <span v-if='getDefectStatus(scope.row,"no")' style='color:red'>不合格</span>
                                <span v-if='getDefectStatus(scope.row,"yes")' style='color:green'>合格</span>
                            </template>
                        </el-table-column>
                    </el-table>
                </div>
        </el-card>
        <el-card class="box-card" style="margin-top:14px">
            <div class="container-header">
                <div class="hign-line"></div>
                <div class="header-left">
                    {{$t('inspectionManagement.comprehensiveJudgment')}}
                </div>
            </div>
            <el-form :model="viewModel" ref="resultForm" :rules="formRules" label-width="120px">
                <el-row :gutter="24" class="mb8">
                    <el-col :span="6">
                        <el-form-item :label="$t('inspectionManagement.destructiveMaterialInformation')" prop="destroyAmount">
                            <!-- <el-input v-model="viewModel.destroyAmount" clearable size="small" @keyup.enter.native="handleQuery" /> -->
                            <el-input-number :step="1" step-strictly :min='0' v-model="viewModel.destroyAmount" clearable :controls="false"
                            size="small"></el-input-number>
                        </el-form-item>
                    </el-col>
                    <el-col :span="14">
                        <el-form-item :label="$t('inspectionManagement.judgmentResult')" prop="judgmentResult" style="height: 50px;">
                            <!-- <span v-if="viewModel.decideResult=='0'||(viewModel.outerPacking==='1')||(viewModel.inspectionRohs==='1')||(viewModel.inspectionCoa==='1'||(viewModel.trialInvestment == '1'))" class="result-tag-red">不合格</span> -->
                            <span v-if="viewModel.decideResult=='0'" class="result-tag-red">不合格</span>
                            <span v-else-if="viewModel.decideResult=='1'" class="result-tag-green">合格</span>
                            <span v-else>暂无判定结果</span>
                        </el-form-item>
                    </el-col>
<!--
                    <el-col :span="6" v-if="true||viewModel.decideResult=='1' && viewModel.inspectionCoa!=1">
                        <el-form-item :label="$t('inspectionManagement.whetherTrial')" prop="returnAmount">
                            <el-select     v-model="viewModel.whetherTrial" style="width: 100%;"
                            clearable size="small" :placeholder="$t('public.select_holder', {select_holder: $t('inspectionManagement.whetherTrial'),})">
                                <el-option v-for="item in isTrialInvestList" :key="item.value"
                                    :label="item.label"  :value="item.value">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="6" v-if="true||viewModel.whetherTrial=='1'">
                        <el-form-item label="假设一次试投不通过是否发起二次试投" prop="twiceTrial">
                            <el-select v-model="viewModel.twiceTrial" style="width: 100%;"
                            clearable size="small" placeholder="请选择">
                                <el-option v-for="item in isTrialInvestList" :key="item.value"
                                    :label="item.label"  :value="item.value">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col> -->

                    <el-col :span="12" >
                        <el-form-item :label="$t('inspectionManagement.COAReportPhotoUpload')"  >
                          <file-upload v-model="viewModel.coaBizType" :otherList="coaBizTypeList"  :bizType="'IncomingCoaBizType'"
                                       :bizId="isReuse === 1 ? JSON.parse(viewModel.coaPic).inspectionId :id" @change="(fileList)=>incomingFileChange3(fileList)"></file-upload>
                        </el-form-item>
                    </el-col>
                    <!-- <el-col :span="12" v-if="true||viewModel.whetherTrial=='1'">
                        <el-form-item label="试投材料附件" prop="trialBizType">
                            <file-upload v-model="viewModel.trialBizType" :otherList="trialBizTypeList"  :bizType="'onceTrialDoc'"
                            :bizId="id" @change="(fileList)=>incomingFileChange2(fileList)"></file-upload>
                        </el-form-item>
                    </el-col> -->

                    <el-col :span="24">
                        <el-form-item :label="$t('inventoryManagement.description')" prop="description" style="width:100%;margin-top: 20px;">
                            <el-input type="textarea" :autosize="{ minRows: 5, maxRows: 6}" v-model="viewModel.description" maxlength="1000">
                            </el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="24">
                        <el-form-item :label="$t('inventoryManagement.uploadAttachments')" prop="uploadAttachments" style="width:100%">
                            <file-upload v-model="viewModel.uploadAttachments" :otherList="otherList" ref="incomingFiles" :bizId="isReuse === 1 ? JSON.parse(viewModel.coaPic).inspectionId :id"
                            @change="(fileList)=>incomingFileChange(fileList)"></file-upload>
                        </el-form-item>
                    </el-col>

                </el-row>
            </el-form>
        </el-card>
        <div class="submit-footer">
            <el-button icon="el-icon-close" size="small" @click="closeTab" class="drawer-close">{{$t('public.close')}}</el-button>
            <!-- <el-button icon="el-icon-refresh" class="resectBtn drawer-close" size="small" @click="closeTab">{{$t('public.reset')}}</el-button> -->

            <el-button type="primary" @click="saveStorage" :loading="loading" icon="el-icon-receiving" size="small">{{$t('public.saveStorage')}}</el-button>
            <el-button type="primary" @click="submitForm" :loading="loading" icon="el-icon-check" v-if="isShowSubmitButton" size="small">{{$t('public.submit')}}</el-button>
            <!-- <el-button type="primary" @click="approvalShow" :loading="loading" icon="el-icon-edit-outline" v-show="viewModel.decideResult=='0'&&viewModel.dataSource!=='库存'&&viewModel.dataSource!=='额外'" size="small">{{$t('performanceManagement.audit')}}</el-button> -->
            <!-- 发起Mrb => 提交按钮 走提交业务逻辑 -->
            <!-- <el-button type="primary" @click="submitForm" :loading="loading" icon="el-icon-check" size="mini" v-if="viewModel.decideResult=='0'">{{$t('public.submit')}}</el-button> -->
            <!-- <el-button type="primary" @click="ncrSubmit" :loading="loading" icon="el-icon-check" size="mini" v-if="viewModel.decideResult=='0'&&(viewModel.dataSource!=='库存'&&viewModel.dataSource!=='额外' ||(viewModel.outerPacking==='1')||(viewModel.inspectionRohs==='1')||(viewModel.inspectionCoa==='1')||(viewModel.trialInvestment == '1')  )">{{$t('inspectionManagement.addNCRApprove')}}</el-button> -->
        </div>
        <!-- 设置到期日期 -->
        <el-dialog title="设置到期日期" :visible.sync="expireTimeOpen" center top="14vh" width="500px" append-to-body :fullscreen="fullscreen">
            <el-form :model="expireForm" ref="expireForm" label-position="top" :rules="expireRules">
                <el-form-item label="使用/不使用" prop="approveStatus">
                    <el-radio-group v-model="expireForm.usingDecision" >
                        <el-radio label="使用">使用</el-radio>
                        <el-radio label="不使用">不使用</el-radio>
                    </el-radio-group>
                </el-form-item>
                <el-form-item label="有效期" prop="expireDate">
                    <el-date-picker format="yyyy-MM-dd" value-format="yyyy-MM-dd" v-model="expireForm.expireDate" size="small" type="date" placeholder="选择日期时间">
                    </el-date-picker>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button type="primary" @click="submitTime" icon="el-icon-check" size="small">{{ $t("public.define") }}</el-button>
            </div>
        </el-dialog>
        <!-- 查看箱号和托盘号 -->
            <el-dialog :title="$t('inspectionManage.viewContainerNumber')" :visible.sync="containerNumberVisble" center top="14vh" width="700px" append-to-body :fullscreen="fullscreen">
                    <el-table :data="containerNumberData" style="width: 100%">
                            <el-table-column prop="boxNo" :label="$t('inspectionManage.viewContainerNumber')" />
                            <!-- TODO: 查看箱号和托盘号 状态未对接-->
                            <el-table-column prop="date" :label="$t('inspectionManage.selectionStatus')" >未挑选</el-table-column>
                            <el-table-column prop="updateTime" :label="$t('inspectionManage.selectionTime')" />
                    </el-table>
                    <pagination
         
          :total="containerNumberPage.total"
          :page.sync="containerNumberPage.pageNum"
          limit.sync="200"
          @pagination="getBoxNoList"
          layout="total,  prev, pager, next"
        />
                </el-dialog>
        <!-- <el-dialog title="选择MRB发起人" :visible.sync="mrbOpen" center top="14vh" width="500px" append-to-body :fullscreen="fullscreen">
            <el-form :model="expireForm" ref="expireForm" label-position="top" :rules="expireRules">
                <el-form-item label="申请人" prop="initiatorName">
                    <select-user-dialog v-model="viewModel.initiatorName" @sendData="(row)=>mrbUserDataCallback(row)" />
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button type="primary" @click="submitMRB" icon="el-icon-check" size="small">{{ $t("public.define") }}</el-button>
            </div>
        </el-dialog> -->
        <biz-select-user-dialog :visible.sync="approvalVisible" :multiple="true" @callback="(names,ids)=>approvalCallback(names,ids)" />
        <importDataDialog :visible.sync="templateVisible2" @callback="templateVisible2=false" ref="importDataDialog" :action="'/ny-iqc/incomingInspection/import'"/>
        <!--import barcode dialog-->
        <importDialog :visible.sync="showImportRelatedBarcode"  @callback="showImportRelatedBarcode=false" ref="importRelatedBarcodeDialog"
        :action="'/ny-iqc/incomingInspection/importScanSampleCode'" :isshowconfirm="true"
        :templateUrl="'/ny-iqc/incomingInspection/exportScanSampleCode'"

        />
        <ScanListDialog :visible.sync="scanVisble" :incomingId="id"/>
       
        <IncomingItemDialog ref="IncomingItemDialogref" v-model="taskModel.divisionName" :usedTypes.sync="usedTypes" @viewtransmissionCurrentType="viewtransmissionCurrentType" :viewModel.sync='viewModel' :incomingItemDialogScope.sync="incomingItemDialogScope" :incomingItemDialogvisible.sync='incomingItemDialogvisible' :divisionId.sync="taskModel.divisionId"/>
    </div>

</template>

<script>
import {refreshCache} from '@/api/basic/dict/type'
import {getNoticeList} from '@/api/system/message'
import FileUploadInput from '@/components/FileUploadInput'
import SupplierDialog from '@/views/components/SupplierDialog'
import MaterialDialog from '@/views/components/MaterialDialog'
import BizSelectUserDialog from '@/views/components/BizSelectUserDialog'
import MeasuringToolDialog from '@/views/components/MeasuringToolDialog'
import SelectUserDialog from '@/views/components/SelectUserDialog'
import copyInspectDataDialog from './copyInspectData.vue'
import {geFileByBiz} from '@/api/file/file'
import {mapGetters} from 'vuex'
import Screenfull from '@/components/Screenfull'
import importDataDialog from '@/views/components/importDialog/importData.vue'
import importDialog from '@/views/components/importDialog/importDialog.vue'
import ScanListDialog from '@/views/components/ScanListDialog'
import IncomingItemDialog from '@/views/components/incomingItemDialog'
import {
  addIncoming,
  addMRBIncoming,
  addNcrIncoming,
  approvalIncoming,
  getFlowByMaterialCode,
  getIncomingDetail,
  getMinFlawAll,
  updateIncoming,
  updateValidityDate
} from '@/api/inspectionManagement/inspectionManagement'
import {listAllMaxFlaw} from '@/api/basic/flawProject'

import { BizTypeEnum } from '@/enums/bizTypeEnum'
import { materialInspectionItemGetItemInfo } from '@/api/basic/typeMaterial'
import {differenceRepairGetOneBy,fetchBoxNoList} from '@/api/inventoryManagement/compensationdifferencevaluesetting.js'

class CheckoutItem {
    "id" = void 0 // 主键
    "checkoutValue"= void 0 // 检验值（合格数）
    "classId"= void 0  // 检验项的主键id
    "result"= void 0 // 判定结果
    "resultValue"= void 0 // 结果值（不合格数）
    "sampleCode"= void 0 // 样本编号
    constructor(id,classId,checkoutValue,resultValue,result,sampleCode){
        this.id = id
        this.classId = classId
        this.checkoutValue = checkoutValue
        this.resultValue = resultValue
        this.result = result
        this.sampleCode = sampleCode

    }
}


export default {
    name: 'inspectionExemption',
    dicts: ['sys_normal_disable','NYIQC_CE_CLASS','NYIQC_CE_STRATEGY'],
    components: {
        IncomingItemDialog,
        FileUploadInput,
        SupplierDialog,
        MaterialDialog,
        MeasuringToolDialog,
        SelectUserDialog,
        BizSelectUserDialog,
        copyInspectDataDialog,
        Screenfull,
        importDataDialog,ScanListDialog,
        importDialog,
    },
    watch: {
        fullscreen(val) {
            if (val === true) {
                this.tableHeight = 'calc(100vh - 158px)'
            } else {
                this.tableHeight = '300'
            }
        },
    },
    data() {
        return {
            tempScope:null,
            noSlect:false,
            applicationStatus:false,
            transmissionCurrentType:{},
            transmissionCurrentTypeOld:{},
            // 应用对照表
            usedTypes:JSON.parse(localStorage.getItem('usedTypes')) || {},
            incomingItemDialogScope:null,
            incomingItemDialogvisible:false,
            taskModel: {

            },
          checkoutList: [], // 所有检验项数据
          displayedCheckoutList: [], // 当前展示的检验项数据
          loadMoreLoading: false, // 是否正在加载数据
          page: 1, // 当前页数
          pageSize: 200, // 每页条数
          hasMore: true, // 是否还有更多数据
            scanVisble:false,
            containerNumberVisble:false,
            containerNumberPage:{
                pageNum:1,
                pageSize:50,
                total:0
            },
            containerNumberData:[],
            BizTypeEnum,
            expireRules:{},
            direction: 'rtl',
            tableHeight: '300',
            expireTimeOpen: false,
            addInspectionExemption: false,
            expireForm: {
                expireDate: null,
                id: null,
                usingDecision: '使用',
            },
            viewModel: {
                lichn: undefined,
                lot: undefined,
                materialName: undefined,
                materialCode: undefined,
                maturity: undefined,
                supplierCode: undefined,
                batchAmount: undefined,
                mengeneinh: undefined,
                exempted: undefined,
                factoryName: undefined,
                amendMeng: undefined,
                amendBatch: undefined,
                inspectionCoa: undefined,
                inspectionRohs: 0,
                outerPacking: 0,
                destroyAmount: 0,
                trialInvestment: "2",

                checkoutResult: void 0, // 本地定义个检验值保存所有检验项的结果
            },
            id: this.$route.params.id,
            templateVisible: false,
            templateVisible2:false,
            showImportRelatedBarcode:false,
            drawer: false,
            approvalOpen: false,
            viewInspectionExemption: false,
            currentItem: {
                projectName: '',
                checkoutType: '',
                lowerLimit: '',
                upperLimit: '',
                samplingAmount: '',
                gap: '',
                flawProjectName: '',
                inspectorName: '',
                row: {},
            },
            addModel: {},
            editModel: {},
            approvalVisible: false,
            typeListKey: 0,
            selBtn: 1,
            // 遮罩层
            loading: false,
            // 选中数组
            ids: [],
            // 非单个禁用
            single: true,
            // 非多个禁用
            multiple: true,
            // 显示搜索条件
            showSearch: true,
            // 总条数
            total: 0,
            // 字典表格数据
            typeList: [],
            CleanTypeList:[],
            tableHeader: [],
            // 弹出层标题
            title: '',
            // 是否显示弹出层
            open: false,
            // 日期范围
            dateRange: [],
            // 查询参数
            queryParams: {
                pageNum: 1,
                pageSize: 20,
                noticeTitle: undefined,
                noticeType: undefined,
                hasRead: undefined,
                createTime: undefined,
            },
            // 表单参数
            form: {},
            incommingRules: {},
            // 综合判定表单校验
            formRules: {
                twiceTrial: [
                    {
                        required: true,
                        message: '选项不能为空'
                    },
                ],
                trialBizType: [
                    {
                        required: true,
                        message: '试投材料附件不能为空'
                    },
                ],
                coaBizType: [
                  {
                    required: true,
                    message: 'COA报告照片不能为空'
                  },
                ],
            },
            // 表单校验
            queryFormRules: {
                flawProjectName: [
                    {
                        required: true,
                        message: '小缺陷不能为空',
                        trigger: 'blur',
                    },
                ],
                inspectorName: [
                    {
                        required: true,
                        message: '检验员不能为空',
                        trigger: 'blur',
                    },
                ],
            },
            fullscreen: false,
            comprehensiveResults: '',
            isAllQualified: 0,
            minFlawOptions: [],
            ifInspect: '',
            isEdit: true,
            isReuse: 0,
            otherList: [],
            itemFileList: [],
            trialBizTypeList:[],
            coaBizTypeList: [],
            rowId: '',
            isTrialInvestList: [
                {
                    label: '是',
                    value: '1'
                },
                {
                    label: '否',
                    value: '0'
                }
            ],
            // 大小缺陷动态选择数据
            maxFlawNameOptions:[],
            minFlawNameOptions: [],
            maxLoading: false,
            minLoading: false,

            tableFormRule: {
                sampleCode: [
                    { required: true, message: '样本编号能为空', trigger: 'blur'},
                ],
                checkoutValue: [
                    { required: true, message: '检验值能为空', trigger: 'blur'},
                ],
            },
            templateVisible2:false,
            overindex:-1,//最后一次提交项
            inspectionFlawList:[],
            Obj:{},
            isShowSubmitButton:false,
            differenceRepairSheet:{}
        }
    },
    computed: {
        ...mapGetters(['userId', 'name']),
        getsamAcCount(){
            return function (scope){
                return this.caculateSome('Ac',scope.row.id)
            }
        },
        getsamReCount(){
            return function (scope){
                return this.caculateSome('Re',scope.row.id)
            }
        },
        getDefectStatus(){
            let that = this
            // console.log(type,'1111111111111')
            return function(item,type){
                console.log('检查是否更新',item,type)
                if(type == 'no'){
                    if(item.samReCr && that.Obj[item.id].samReCountCr >= item.samReCr){
                        item.result = 0
                        return true
                    }else if(item.samReMa && that.Obj[item.id].samReCountMa >= item.samReMa){
                        item.result = 0
                        return true
                    }else if(item.samReMi && that.Obj[item.id].samReCountMi >= item.samReMi){
                        item.result = 0
                        return true
                    }else return false
                }else if(type == 'yes'){
                    let tempObj = {}
                    let keyObj = {}
                        if(item.samReCr){
                            tempObj.samReCr = item.samReCr
                            keyObj.samReCr = that.Obj[item.id].samReCountCr
                        }
                        if(item.samReMa){
                            tempObj.samReMa = item.samReMa
                            keyObj.samReMa = that.Obj[item.id].samReCountMa
                        }
                        if(item.samReMi){
                            tempObj.samReMi = item.samReMi
                            keyObj.samReMi = that.Obj[item.id].samReCountMi
                        }
                        console.log(tempObj,keyObj)
                        for (const key in tempObj) {
                            if (Object.hasOwnProperty.call(tempObj, key)) {
                                if(tempObj[key] <= keyObj[key]){
                                    return false
                                }
                                
                            }
                        }
                        item.result = 1
                        return true
                }
            }
        }
    },
    created() {
          this.getIncomingDetail(this.id)
          // this.getIncomingDetail(this.id)
        this.getList()

    },
    mounted() {
        //监听键盘按键事件
        let self = this
        window.onresize = function () {
            if (!self.checkFull()) {
                // 退出全屏后要执行的动作
                self.fullscreen = false
            }
        }
    },
    methods: {
        Cdv(){
            differenceRepairGetOneBy({
            projectCode:this.currentItem.projectCode,
            supplierCode:this.viewModel.supplierCode,
            divisionId:this.viewModel.divisionId,
            factoryCode:this.viewModel.factoryCode}).then(res => {
                if(res.data){
                    for (const iterator of this.displayedCheckoutList) {
                        for (const j of iterator.checkoutItemList) {
                            let checkoutValue = j.checkoutValue
                            j.checkoutValue =  String(((Number(checkoutValue ? checkoutValue : 0) * 10000000000) + (Number(res.data.difference) * 10000000000)) / 10000000000)
                            this.acceptChangeItem(j.checkoutValue,{row:j})
                        }
                    }
                    this.differenceRepairSheet[this.currentItem.id] = true
                }else{
                    this.$modal.msgError('未查询到补偿差异值，请前往补偿差异值设置页面维护')
                }
            })
        },
        tableRowClassNameDefect({ row, rowIndex }) {
            if(row.samplingOne === '固定抽样'){
                return 'table-hidden-row'
            }
            if (row.isHighLight === true) {
                return 'rowHighLight' //若isHighLight为true，则使用“rowHighLight”样式
            } else {
                return ''
            }
        },
        caculateAsyncDefect(){
            // inspectionFlawList缺陷项一对多检验项
            let Obj = {}
			if(this.typeList && this.typeList.length && this.inspectionFlawList && this.inspectionFlawList.length){
				for (let s of this.inspectionFlawList) {
					let itemIdListCR = typeof s.itemClassIdCr == 'string' ? s.itemClassIdCr.split(',') : []
                    let itemIdListMA = typeof s.itemClassIdMa == 'string' ? s.itemClassIdMa.split(',') : []
                    let itemIdListMI = typeof s.itemClassIdMi == 'string' ? s.itemClassIdMi.split(',') : []
					Obj[s.id] = {}
					// Obj[s.id]['samAcCount'] = 0
                    Obj[s.id]['samReCountCr'] = itemIdListCR.length ? 0 : ''
                    Obj[s.id]['samReCountMa'] = itemIdListMA.length ? 0 : ''
                    Obj[s.id]['samReCountMi'] = itemIdListMI.length ? 0 : ''
                    let that = this
                    let caculateItem = function(item,samKey){
                        for (let i of item) {
                            for (let d of that.typeList) {
                                if(i == d.id && d.checkoutType == '数值'){
                                    let tempCheckoutList = JSON.parse(JSON.stringify(d.checkoutList))
                                    let CheckoutObj = {}

                                    for (const iterator of tempCheckoutList) {
                                        CheckoutObj[iterator.sampleCode] = iterator
                                    }
                                    for (const key in CheckoutObj) {
                                        if (CheckoutObj.hasOwnProperty.call(CheckoutObj, key)) {
                                            if(CheckoutObj[key].singleResult === '1' || CheckoutObj[key].singleResult === 1){
                                                // Obj[s.id]['samAcCount'] += 1
                                            }else if (CheckoutObj[key].singleResult === '0' || CheckoutObj[key].singleResult === 0){
                                                Obj[s.id][samKey] += 1
                                            }
                                        }
                                    }
                                }else if (i == d.id && d.checkoutType != '数值'){
                                    if(d.samplingOne == '固定抽样'){
                                        if(d.checkoutResult !== '' && d.checkoutResult !== null){
                                            Obj[s.id][samKey] += (d.samplingAmount - d.qualifiedNum)
                                        }
                                    }else if(d.samplingOne == 'GB/T2828.1-2012'){
                                        if(d.checkoutResult !== '' && d.checkoutResult !== null){
                                            Obj[s.id][samKey] += Number(d.resultValue)
                                        }
                                    }else{
                                        for (const j of d.checkoutList) {
                                            if(j.result === 1 || j.result === '1'){
                                                // Obj[s.id]['samAcCount'] += 1
                                            }else if (j.result === 0 || j.result === '0'){
                                                Obj[s.id][samKey] += 1
                                            }
                                        }
                                    } 
                                }
                            }
                        }
                    }
                    caculateItem(itemIdListCR,'samReCountCr')
                    caculateItem(itemIdListMA,'samReCountMa')
                    caculateItem(itemIdListMI,'samReCountMi')
				}
			}
            this.Obj = {...this.Obj,...Obj}
            console.log(this.Obj,'缺陷统计结果！！！！！！！！！')
        },
        // caculateSome(name,staticId){
		// 	// inspectionFlawList缺陷项一对多检验项
		// 	if(this.typeList && this.typeList.length && this.inspectionFlawList && this.inspectionFlawList.length){
		// 		for (let s of this.inspectionFlawList) {
		// 			let itemIdList = s.checkItemClassId.split(',')
		// 			this.Obj[s.id] = {}
		// 			this.Obj[s.id]['sam'+name+'Count'] = 0
		// 			for (let i of itemIdList) {
		// 				for (let d of this.typeList) {
		// 					if(i == d.id){
		// 						console.log('我应该出现classList.length*2次'+i+name)
		// 						this.Obj[s.id]['sam'+name+'Count'] += Number(d['sam'+name])
		// 					}
		// 				}
		// 			}
		// 		}
        //         return this.Obj[staticId]['sam'+name+'Count']
		// 	}
        //     console.log(this.Obj,'hhhhh',name)
		// 	return '空'
		// },
        // 查看共享检验数据项
        viewtransmissionCurrentType(obj){
            // console.log('hhhhhhhhhhhhhhh')
            this.transmissionCurrentTypeOld = obj
            if(obj.type == 'simple'){
                console.log(obj.item,'应用数据')
                materialInspectionItemGetItemInfo(obj.item.itemId).then(res => {
                    console.log(res.data,'检验项数据详情')
                    this.handleEdit({row:res.data},true)
                    this.transmissionCurrentType = res.data
                    console.log(this.applicationStatus,'应用按钮显示')
                    // this.$forceUpdate()
                    // this.incomingItemDialogScope.checkoutList = res.data.checkoutList
                    // this.incomingItemDialogScope.flawList = res.data.flawList
                    // this.incomingItemDialogScope.checkoutResult = res.data.checkoutResult

                })
            }else{
                // this.applicationStatus = true
                console.log(obj.item,'应用数据')
                materialInspectionItemGetItemInfo(obj.item.itemId).then(res => {
                    console.log(res.data,'检验项数据详情')
                    this.handleEdit({row:res.data},false)
                    this.transmissionCurrentType = res.data
                    this.incomingItemDialogScope.checkoutList = res.data.checkoutList
                    this.incomingItemDialogScope.flawList = res.data.flawList
                    this.incomingItemDialogScope.checkoutResult = res.data.checkoutResult
                    this.incomingItemDialogScope.dataSoureFlag = 1
                    this.usedTypes[this.incomingItemDialogScope.itemId+','+this.tempScope.row.id] = obj.item.itemId
                    // localStorage.setItem('usedTypes',JSON.stringify(this.usedTypes))
                    this.$refs['IncomingItemDialogref'].rfreshStatus()
                    console.log(this.usedTypes,'最多只有当前检验项数量')
                    this.$modal.msgSuccess('应用成功!')
                    // this.$forceUpdate()

                })
            }
            // this.drawer = true
        },
      loadMore() {
        this.loadMoreLoading = true;
        // 模拟从服务器获取更多数据的过程
        setTimeout(() => {
          const start = (this.page - 1) * this.pageSize;
          const end = start + this.pageSize;
          console.log(this.currentItem.checkoutList)
          const dataSlice = this.currentItem.checkoutList.slice(start, end); // 从模拟数据中切片获取数据
          this.displayedCheckoutList = this.displayedCheckoutList.concat(dataSlice); // 追加数据到表格数据
          this.loadMoreLoading = false;
          if (end >= this.currentItem.checkoutList.length) {
            this.hasMore = false; // 已加载完所有数据
          }
          this.page++;
        }, 500); // 模拟延迟
      },
      focusNextInput(currentInput,itemT,indexT) {
        // 这里可以根据当前输入框的索引决定下一个输入框是哪个
        // 例如，如果 currentInput 是 1，则跳到 input2
        // 如果 currentInput 是 2，则跳到 input3

        // 尝试获取下一个输入框的 ref
        const nextInputRef = this.$refs[`input.${indexT}.${currentInput + 1}`];

        if (nextInputRef !== undefined && nextInputRef.length > 0) {
          // 如果找到了下一个输入框，设置焦点
          nextInputRef[0].focus();
          nextInputRef[1].focus();
        }else {
          let checkoutItemListElement = itemT.checkoutItemList[currentInput];
          if (checkoutItemListElement){
            const nextInputRef = this.$refs[`input.${indexT+1}.0`];
            if (nextInputRef !== undefined && nextInputRef.length > 0) {
              // 如果找到了下一个输入框，设置焦点
              nextInputRef[0].focus();
              nextInputRef[1].focus();
            }
          }
        }
      },
        showglb(){
            // var data={
            //     incomingId:this.id
            // }
            // listScanSampleCodeAPI(data).then(res=>{
                this.scanVisble=true
            // })
        },
        showContainerNumber() {
           const containerNumberPage = {
                inspectionId:this.id,
                pageNum:1,
                pageSize:50
            }
            fetchBoxNoList(containerNumberPage).then(res=>{
                this.containerNumberData = res.rows;
                containerNumberPage.total = res.total
                this.containerNumberVisble = true;
                this.containerNumberPage = containerNumberPage
            })
          
        },
       getBoxNoList(data){
            const {page} = data;
            const containerNumberPage = this.containerNumberPage
            containerNumberPage.pageNum = page;
            fetchBoxNoList(containerNumberPage).then(res=>{
                containerNumberPage.total = res.total
                this.containerNumberData = res.rows;
                this.containerNumberPage = containerNumberPage
            })
           
        },
        //show dialog to import barcode
        showImortRlatedBarcod(){
           this.showImportRelatedBarcode=true;
           console.log('id is:',this.id);
          this.$refs.importRelatedBarcodeDialog.params={id:this.id};
        },
        handleImport(){
            this.templateVisible2= true
            this.$refs.importDataDialog.loadFileParams.id=this.id
        },
        formatCE_CLASS(e) {
            if (e) {
                let obj = this.dict.type.NYIQC_CE_CLASS.find((item) => {
                    return item.value === e
                })
                if (obj) {
                    return obj.label
                } else {
                    return ''
                }
            } else {
                return ''
            }
        },
        formatCE_STRATEGY(e) {
            if (e) {
                let obj = this.dict.type.NYIQC_CE_STRATEGY.find((item) => {
                    return item.value === e
                })
                if (obj) {
                    return obj.label
                } else {
                    return ''
                }
            } else {
                return ''
            }
        },
        remarkRenderHeader(h, { column, $index }) {
            return h('span', [
                h(
                    'span',
                    {
                        style: {
                            color: '#ff1818',
                        },
                    },
                    '*'
                ),
                h('span', column.label),
            ])
        },
        minFlawRules(row, index) {
            return [
                {
                    require: true,
                    validator: (rule, value, callback) => {
                        if (
                            value === null ||
                            value === undefined ||
                            value === ''
                        ) {
                            return callback(new Error('小缺陷不能为空'))
                        }
                        callback()
                    },
                    trigger: 'change',
                },
            ]
        },
        minFlawNrRules(row, index) {
            return [
                {
                    require: true,
                    validator: (rule, value, callback) => {
                        if (
                            value === null ||
                            value === undefined ||
                            value === ''
                        ) {
                            return callback(new Error('缺陷数量不能为空'))
                        }
                        if ((/[.]/.test(value))) {
                            return callback(new Error('不能为小数'))
                        }
                        callback()
                    },
                    trigger: 'blur',
                }
            ]
        },
        unitRemoteMethod(val, cb, maxFlawId) {
            if (
                maxFlawId === '' ||
                maxFlawId === null ||
                maxFlawId === undefined
            ) {
                cb([])
                return
            }
            getMinFlawAll({ maxFlawId: maxFlawId, minFlawName: val }).then(
                (res) => {
                    cb(res.data)
                }
            )
        },
        maxRemoteMethod(val, cb) {
            listAllMaxFlaw({ maxFlawName: val }).then((res) => {
                cb(res.data)
            })
        },
        mrbUserDataCallback(row) {
            this.viewModel.initiatorId = row.userId
            this.viewModel.initiatorDept = row.deptName
        },
        deleteFlaw(scope) {
            this.currentItem.flawList.splice(scope.$index, 1)
        },
        changeMaxFlaw(value, scope) {
            const item = value?this.maxFlawNameOptions.find(i=>i.maxFlawName == value):{}
            this.currentItem.flawList[scope.$index].maxFlawName =
                item.maxFlawName
            this.currentItem.flawList[scope.$index].maxFlawCode =
                item.maxFlawCode
            this.currentItem.flawList[scope.$index].maxFlawId = item.id
            this.currentItem.flawList[scope.$index].minFlawName = ''
        },
        changeFlaw(value, scope) {
            const item = value?this.minFlawNameOptions.find(i=>i.minFlawName == value):{}
            this.currentItem.flawList[scope.$index].minFlawName =
                item.minFlawName
            this.currentItem.flawList[scope.$index].minFlawCode =
                item.minFlawCode
            this.currentItem.flawList[scope.$index].minFlawId = item.id
        },
        addFlaw() {
            this.currentItem.flawList.push({
                minFlawNr: null,
                minFlawName: null,
                minFlawId: null,
                minFlawCode: null,
                classId: this.currentItem.id,
            })
        },
        outerPackingChange() {
            this.rebuildResult()
        },
        inspectionRohsChange() {
            this.rebuildResult()
        },
        inspectionCoaChange() {
            this.rebuildResult()
        },
        rebuildResult() {
            // 校验检验项结果
            this.buildInspectionResult()
            this.caculateAsyncDefect()
            console.log('检验项结果',this.viewModel.checkoutResult)
            if ( // 有一个不合格，则都不合格
                this.viewModel.outerPacking === '1' ||
                this.viewModel.inspectionRohs === '1' ||
                this.viewModel.inspectionCoa == '1' ||
                this.viewModel.trialInvestment == "1" ||
                this.viewModel.checkoutResult == "0"
            ) {
                this.viewModel.decideResult = '0'
            }
            // 合格
            if (
                this.viewModel.outerPacking === '0' &&
                this.viewModel.inspectionRohs === '0' &&
                this.viewModel.inspectionCoa != '1' &&
                this.viewModel.trialInvestment != "1" &&
                this.viewModel.checkoutResult == '1'
            ) {
                this.viewModel.decideResult = '1'
            }

            for (const iterator of this.inspectionFlawList) {
                if(iterator.samplingOne === '固定抽样') {

                }else{
                    if(this.Obj[iterator.id].samReCountCr >= iterator.samReCr && iterator.samReCr){

                        this.viewModel.decideResult = '0'
                        break;
                    }
                    if(this.Obj[iterator.id].samReCountMa >= iterator.samReMa && iterator.samReMa){

                        this.viewModel.decideResult = '0'
                        break;
                    }
                    if(this.Obj[iterator.id].samReCountMi >= iterator.samReMi && iterator.samReMi){

                        this.viewModel.decideResult = '0'
                        break;
                    }
                }
            }

            console.log('this.viewModel.outerPacking',this.viewModel.outerPacking)
            console.log('this.viewModel.inspectionRohs',this.viewModel.inspectionRohs)
            console.log('this.viewModel.inspectionCoa',this.viewModel.inspectionCoa)
            console.log('this.viewModel.trialInvestment',this.viewModel.trialInvestment)
            console.log('this.viewModel.checkoutResult',this.viewModel.checkoutResult)
            console.log('this.viewModel.decideResult',this.viewModel.decideResult)
        },
        checkFull() {
            //判断浏览器是否处于全屏状态 （需要考虑兼容问题）
            //火狐浏览器
            var isFull =
                document.mozFullScreen ||
                document.fullScreen ||
                //谷歌浏览器及Webkit内核浏览器
                document.webkitIsFullScreen ||
                document.webkitRequestFullScreen ||
                document.mozRequestFullScreen ||
                document.msFullscreenEnabled
            if (isFull === undefined) {
                isFull = false
            }
            return isFull
        },
        nextInput(className, index) {
            if (
                parseInt(index) + 1 ===
                this.currentItem.inspectionValues.length
            ) {
                return
            }
            let ele = document.querySelector(
                '.' + className + ' .el-input__inner'
            )
            // let inputDoms = ele.querySelectorAll('.el-input__inner')
            console.log(ele)
            ele.focus()
            // console.log(document.getElementsByClassName(className))
        },
        changeFull() {
            const element = document.getElementById('fullscreen')
            if (this.fullscreen) {
                if (document.exitFullscreen) {
                    document.exitFullscreen()
                } else if (document.webkitCancelFullScreen) {
                    document.webkitCancelFullScreen()
                } else if (document.mozCancelFullScreen) {
                    document.mozCancelFullScreen()
                } else if (document.msExitFullscreen) {
                    document.msExitFullscreen()
                }
            } else {
                if (element.requestFullscreen) {
                    element.requestFullscreen()
                } else if (element.webkitRequestFullScreen) {
                    element.webkitRequestFullScreen()
                } else if (element.mozRequestFullScreen) {
                    element.mozRequestFullScreen()
                } else if (element.msRequestFullscreen) {
                    // IE11
                    element.msRequestFullscreen()
                }
            }
            this.fullscreen = !this.fullscreen
        },
        handleMinFlawSelect(e) {
            // this.dialogForm.materialType = e
            this.currentItem.flawProjectName = e.minFlawName
            this.$forceUpdate()
        },

        async geFileByBizlist(id) {
            await geFileByBiz({ bizId: this.isReuse === 1 ? JSON.parse(this.viewModel?.coaPic)?.inspectionId :id }).then((res) => {
                let otherList = []
                let trialBizTypeList=[]
                let coaBizTypeList=[]
                res.data.forEach((io) => {
                    if (io.bizType === 'UPLOAD_FILE_OTHERS') {
                        otherList.push(io)
                    }
                    if (io.bizType === 'onceTrialDoc') {
                        trialBizTypeList.push(io)
                    }
                    if (io.bizType === 'IncomingCoaBizType') {
                        coaBizTypeList.push(io)
                    }
                })
                this.otherList = otherList
                this.trialBizTypeList=trialBizTypeList
                this.coaBizTypeList=coaBizTypeList


            })

            await geFileByBiz({bizId: this.isReuse === 1 ? JSON.parse(this.viewModel?.coaPic)?.extraId : this.viewModel.extraId}).then((rest) => {
                rest.data.forEach((io) => {
                    if (io.bizType === 'IncomingCoaBizType') {
                        this.coaBizTypeList.unshift(io)
                    }
                })
            })
            // this.$forceUpdate()

        },

        getItemFileByIdForItem(id) {
            geFileByBiz({ bizId: id }).then((res) => {
                let itemFileList = []

                res.data.forEach((io) => {
                    if (io.bizType === 'UPLOAD_FILE_ITEM') {
                        itemFileList.push(io)
                    }

                })
                this.itemFileList = itemFileList

                this.$forceUpdate()
            })
        },
        incomingFileChange(e) {
            let ids = e.map((item) => item.id)
            console.log('-------', ids)
            if (ids.length) {
                this.viewModel.fileId = ids.join(',')
            }
        },
        incomingFileChange2(fileList) {
            var filePath=fileList[0].name
            var index= filePath.lastIndexOf(".");
            var ext = filePath.substr(index+1);
            this.viewModel.trialBizType=ext
            console.log(fileList,"fileList")
            this.$forceUpdate()
        },
        incomingFileChange3(fileList) {
            var filePath=fileList[0].name
            var index= filePath.lastIndexOf(".");
            var ext = filePath.substr(index+1);
            this.viewModel.coaBizType=ext
            console.log(fileList,"fileList")
            // this.geFileByBizlist(this.id)
            this.$forceUpdate()
        },
        approvalShow() {
            if (this.viewModel.amendBatch > 0) {
                if (this.viewModel.destroyAmount > this.viewModel.amendBatch) {
                    this.$modal.msgError('破坏性物料数量不能大于修正批数量!')
                    return
                }
            } else {
                if (this.viewModel.destroyAmount > this.viewModel.batchAmount) {
                    this.$modal.msgError('破坏性物料数量不能大于原批数量!')
                    return
                }
            }
            this.approvalVisible = true
        },
        submitMRB() {
            let typeList = [...this.typeList]
            console.log(typeList)
            let submitData = {
                ...this.viewModel,
                classList: typeList,
            }
            addMRBIncoming(submitData)
                .then((response) => {
                    if (response.code == 200) {
                        this.$modal.msgSuccess('提交成功!')
                        this.$router.push({ path: '/inspect/incoming' })
                    } else {
                        this.$modal.msgError(response.msg)
                    }
                })
                .catch((error) => {
                    this.loading = false
                })
        },
        ncrSubmit() {
            if (this.viewModel.amendBatch > 0) {
                if (this.viewModel.destroyAmount > this.viewModel.amendBatch) {
                    this.$modal.msgError('破坏性物料数量不能大于修正批数量!')
                    return
                }
            } else {
                if (this.viewModel.destroyAmount > this.viewModel.batchAmount) {
                    this.$modal.msgError('破坏性物料数量不能大于原批数量!')
                    return
                }
            }
            this.$refs['resultForm'].validate((valid) => {
                if (valid) {
                    this.loading = true
                    let typeList = [...this.typeList]
                    console.log(typeList)
                    let submitData = {
                        ...this.viewModel,
                        classList: typeList,
                    }
                    console.log(JSON.stringify(submitData))
                    addNcrIncoming(submitData)
                        .then((response) => {
                            if (response.code == 200) {
                                this.$modal.msgSuccess('提交成功!')
                                this.$router.push({ path: '/inspect/incoming' })
                            } else {
                                this.$modal.msgError(response.msg)
                            }
                        })
                        .catch((error) => {
                            this.loading = false
                        })
                } else {
                    console.log('error submit!!')
                    return false
                }
            })
        },
        updateInspect(id) {
            getIncomingDetail(id).then((response) => {
                let typeList = response.data.classList
                this.inspectionFlawList = response.data.inspectionFlawList
                this.viewModel.copyItemClassId = response.data.itemClassId
                typeList.forEach((io) => {
                    io.inspector = this.userId
                    io.comprehensiveResults = ''
                    if (io.inspector) {
                        io.checkoutResult = this.getCheckoutResult(
                            io.checkoutValue,
                            io.upperLimit,
                            io.lowerLimit,
                            io.gap,
                            io.checkoutType,
                            io.decimalPlace
                        )
                    }
                    console.log(this.name)
                    // if(){

                    // }
                })
                console.log(typeList, 'typeList')
                this.typeList = typeList
                this.buildInspectionResult()
                this.caculateAsyncDefect()               
                this.isEdit = false
            })
        },
        submitBase() {
            this.drawer = false
            let itemResult = 1
            let checkoutValue = ''
            let resultValue = ''
            let values = []
            let resultValues = []
            console.log(this.currentItem.inspectionValues)
            this.currentItem.inspectionValues.forEach((io) => {
                values.push(io.inspectionValue)
                resultValues.push(io.resultValue)
                if (io.resultType === 0) {
                    itemResult = 0
                }
            })
            console.log('dram提交表单',this.currentItem)
            if(this.currentItem.checkoutType =='数值'){
                if (this.currentItem.singleSample==1) {
                    // 保存检验项
                    let checkoutList = [];
                    this.currentItem.checkoutList.forEach(i=>{
                        i.checkoutItemList.forEach(j=>{
                            j.sampleCode = i.sampleCode
                            j.classId = this.currentItem.id
                            if(j.checkoutValue =='0' || j.checkoutValue) {
                                checkoutList.push({
                                    ...j,
                                    singleValue:i.singleValue,
                                    singleResult:i.singleResult
                                })
                            }
                        })
                    })
                    console.log('checkoutList---->',checkoutList)
                    // 保存检验项列表 checkoutList
                    this.typeList[this.currentItem.index].checkoutList = checkoutList

                }else{
                    // 保存检验项
                    let checkoutList = [];
                    this.currentItem.checkoutList.forEach(i=>{
                        i.checkoutItemList.forEach(j=>{
                            j.sampleCode = i.sampleCode
                            j.classId = this.currentItem.id
                            if(j.checkoutValue =='0' || j.checkoutValue) checkoutList.push({...j})
                        })
                    })
                    console.log('checkoutList---->',checkoutList)
                    // 保存检验项列表 checkoutList
                    this.typeList[this.currentItem.index].checkoutList = checkoutList
                    this.CleanTypeList[this.currentItem.index].checkoutList = checkoutList
                }

            }else {
                // 保存检验项
                let checkoutList = [];
                // 将inspectionValues 传给 checkoutList
                checkoutList = this.currentItem.inspectionValues.map(item=>(
                    new CheckoutItem(
                        null,
                        this.currentItem?.id,
                        item.inspectionValue,
                        item.resultValue,
                        item.resultType,
                        item.singleResult,
                        item.singleValue,
                        null,
                    )
                ))
                console.log('checkoutList---->',checkoutList)
                // 保存检验项列表 checkoutList
                this.typeList[this.currentItem.index].checkoutList = checkoutList
            }
            checkoutValue = values.join(',')
            resultValue = resultValues.join(',')
            this.typeList[this.currentItem.index].checkoutValue = checkoutValue
            this.typeList[this.currentItem.index].flawList =
                this.currentItem.flawList
            this.typeList[this.currentItem.index].result = itemResult
            this.typeList[this.currentItem.index].inspectorName =
                this.currentItem.inspectorName
            this.typeList[this.currentItem.index].fileId =
                this.currentItem.fileId
            this.typeList[this.currentItem.index].inspector =
                this.currentItem.inspector
            this.typeList[this.currentItem.index].resultValue = resultValue

            this.typeList[this.currentItem.index].description =
                this.currentItem.classRemark
            this.typeList[this.currentItem.index].singleSample =  this.currentItem.singleSample
            this.typeList[this.currentItem.index].qualifiedNum =  this.currentItem.qualifiedNum
            // this.typeListKey++
            if (this.comprehensiveResults === '合格') {
                this.typeList[this.currentItem.index].checkoutResult = 1
            }
            if (this.comprehensiveResults === 'NA') {
                this.typeList[this.currentItem.index].checkoutResult = 2
            }
            if (this.comprehensiveResults === '不合格') {
                this.typeList[this.currentItem.index].checkoutResult = 0
            }
            if (this.comprehensiveResults === '') {
                this.typeList[this.currentItem.index].checkoutResult = ''
            }
            if (this.comprehensiveResults === '不合格') {
                this.typeList[this.currentItem.index].flawProjectName = this
                    .currentItem.flawProjectName
                    ? this.currentItem.flawProjectName.join(';')
                    : this.currentItem.flawProjectName
            } else {
                this.typeList[this.currentItem.index].flawProjectName =
                    undefined
            }

            this.typeList[this.currentItem.index].classRemark =
                this.currentItem.classRemark

            // 最小值、最大值、平均值、差值
            this.typeList[this.currentItem.index].minimum = this.currentItem.minimum
            this.typeList[this.currentItem.index].maximum = this.currentItem.maximum
            this.typeList[this.currentItem.index].meanValue = this.currentItem.meanValue
            this.typeList[this.currentItem.index].rangeValue = this.currentItem.rangeValue
            // 同步编码值时判断最后一次填的是哪项
            if(this.currentItem.checkoutTypeCopy=="计量"){
                this.overindex=this.currentItem.index
            }


            this.comprehensiveResults = ''

            // this.buildInspectionResult()
            // 构建整体检验结果
            this.rebuildResult();
            this.$forceUpdate()
            console.log('this.typeList========', this.typeList)
            this.hasMore = true
            this.displayedCheckoutList=[]
            this.currentItem.checkoutList=[]
            this.page=1
            this.pageSize=200
        },
        // disabledForm(){
        //     let usedTypes = JSON.parse(localStorage.getItem('usedTypes'))
        //     if(usedTypes[this.incomingItemDialogScope.itemId]){
        //         this.noSlect = true
        //     }
        // },
        application() {

            this.incomingItemDialogScope.checkoutList = this.transmissionCurrentType.checkoutList
            this.incomingItemDialogScope.flawList = this.transmissionCurrentType.flawList
            this.incomingItemDialogScope.checkoutResult = this.transmissionCurrentType.checkoutResult
            this.incomingItemDialogScope.dataSoureFlag = 1
            this.drawer = false
            this.usedTypes[this.incomingItemDialogScope.itemId+','+this.tempScope.row.id] = this.transmissionCurrentTypeOld.item.itemId
            // localStorage.setItem('usedTypes',JSON.stringify(this.usedTypes))
            this.$refs['IncomingItemDialogref'].rfreshStatus()
            console.log(this.usedTypes,'最多只有当前检验项数量')
            this.$modal.msgSuccess('应用成功!')
        },
        drawerSubmit() {
            this.$refs['currentQueryForm'].validate((valid1) => {
                if (valid1) {
                    if (
                        this.comprehensiveResults === '不合格' &&
                        this.currentItem.flawList.length === 0
                    ) {
                        this.$modal.msgError('请至少添加一条缺陷!')
                        return
                    }
                    console.log(this.$refs['tableFormRef'])
                    let tableFormValid = true;
                    if(Array.isArray(this.$refs['tableFormRef'])){
                        this.$refs['tableFormRef'].forEach(item=>{
                            item.validate((valid2) =>{
                                if(!tableFormValid) return
                                tableFormValid = valid2
                            })
                        })
                    }else {
                        this.$refs['tableFormRef']?.validate(valid2=>tableFormValid = valid2)
                    }
                    if(!tableFormValid) return this.$modal.msgError('请完成样本检验项表单')
                    if (!this.loadMoreLoading && parseInt(this.currentItem.samplingAmount) > this.displayedCheckoutList.length && this.currentItem.checkoutType==='数值') return this.$modal.msgError('请点击加载更多完成所有样本检验项表单')
                    // 取消缺陷表单校验
                    if (this.$refs['formTable'] && false) {
                        this.$refs['formTable'].validate((valid) => {
                            if (valid) {
                                let fallCount = 0
                                this.currentItem.flawList.forEach((io) => {
                                    fallCount += parseInt(io.minFlawNr)
                                })
                                if (
                                    parseInt(fallCount) >
                                    parseInt(this.currentItem.samplingAmount)
                                ) {
                                    this.$modal.msgError(
                                        '缺陷总数不能大于抽样数量!'
                                    )
                                    return
                                }
                                this.submitBase()
                            }
                        })
                    }
                    else{
                        this.submitBase()
                    }
                }
            })
        },
        //判断是否合格
        buildInspectionResult() {
            let failResultCount = 0
            let passResultCount = 0
            let unsetResultCount = 0
            let naResultCount = 0
            let isShowSubmitCount = 0
            this.typeList.forEach((io) => {
                // 记录不合格
                if (io.checkoutResult == '0') {
                    failResultCount++
                    isShowSubmitCount++
                }
                // 记录合格
                if (io.checkoutResult == '1') {
                    passResultCount++
                    isShowSubmitCount++
                }
                // 记录 NA
                if (io.checkoutResult == '2') {
                    naResultCount++
                    isShowSubmitCount++
                }
                // 记录未录入
                if (io.checkoutResult === '') {
                    unsetResultCount++
                }
                // 未填并且有已检标识
                if (io.checkoutResult === null && io.passFlag ==1) {
                    isShowSubmitCount++
                }
                console.log(passResultCount)
            })
            console.log(this.typeList,failResultCount, 'failResultCount===================',isShowSubmitCount)

            
            if(isShowSubmitCount==this.typeList.length){
                this.isShowSubmitButton=true
                if (failResultCount >0) {
                    this.viewModel.checkoutResult = 0
                } else {
                    this.viewModel.checkoutResult = 1
                }
            }
            // this.viewModel.checkoutResult { 0: 不合格， 1：合格， ''：未录入 }
            console.log('passResultCount',passResultCount)
            console.log('checkoutResult',this.viewModel.checkoutResult)
        },
        userDataCallback(id) {
            this.currentItem.inspector = id
        },
        // valueChange(e, scope, index) {
        //     console.log(e)
        //     this.typeList[scope.$index]['value' + index] = e
        //     let checkoutResult = 1
        //     for (
        //         let i = 0;
        //         i < this.typeList[scope.$index].samplingAmount;
        //         i++
        //     ) {
        //         let resultValue =
        //             parseFloat(e) +
        //             (this.typeList[scope.$index].gap &&
        //             this.typeList[scope.$index].gap.length > 0
        //                 ? parseFloat(this.typeList[scope.$index].gap)
        //                 : 0)
        //         console.log(resultValue)
        //         if (
        //             resultValue >
        //                 parseFloat(this.typeList[scope.$index].upperLimit) ||
        //             resultValue <
        //                 parseFloat(this.typeList[scope.$index].lowerLimit)
        //         ) {
        //             checkoutResult = 0
        //         }
        //     }
        //     this.typeList[scope.$index].checkoutResult = checkoutResult
        //     console.log(checkoutResult)
        //     this.judgeQualifid()
        //     this.$forceUpdate()
        // },
        acceptChange2(e){
            if (parseFloat(e) > parseFloat(this.currentItem.samplingAmount) ) {
                this.$modal.msgError('合格数量不能超过抽样数量!')
                this.currentItem.qualifiedNum=0
                    return
            }
        },
        acceptChange(e, scope) {
            if (e === '' || e === null || e === undefined) {
                this.currentItem.inspectionValues[scope.$index].resultType = ''
                this.currentItem.inspectionValues[scope.$index].resultValue = ''
            } else {
                let resultValue = undefined
                if (
                    parseFloat(e) > parseFloat(this.currentItem.samplingAmount)
                ) {
                    this.$modal.msgError('合格数量不能超过抽样数量!')
                    this.currentItem.inspectionValues[
                        scope.$index
                    ].inspectionValue = this.currentItem.samplingAmount
                    resultValue = 0
                } else {
                    resultValue =
                        parseFloat(this.currentItem.samplingAmount) -
                        parseFloat(e)
                }

                console.log(resultValue)
                let resultType = 1
                if (this.currentItem.samplingOne === 'GB/T2828.1-2012') {
                    resultValue = resultValue.toFixed(0)
                    if (
                        parseInt(resultValue) >
                            parseInt(this.currentItem.samRe) ||
                        parseInt(resultValue) ===
                            parseInt(this.currentItem.samRe)
                    ) {
                        resultType = 0
                    }
                    this.currentItem.inspectionValues[
                        scope.$index
                    ].resultValue = resultValue
                    this.currentItem.inspectionValues[scope.$index].resultType =
                        resultType
                }
                if (this.currentItem.samplingOne === 'GB/T2828.2-2008') {
                    resultValue = resultValue.toFixed(0)
                    if (
                        parseInt(resultValue) > parseInt(this.currentItem.samAc)
                    ) {
                        resultType = 0
                    }
                    this.currentItem.inspectionValues[
                        scope.$index
                    ].resultValue = resultValue
                    this.currentItem.inspectionValues[scope.$index].resultType =
                        resultType
                }
            }

            this.judgeQualifid()
            this.$forceUpdate()
        },
        valueChange(e, scope) {
            if (e === '' || e === null || e === undefined) {
                this.currentItem.inspectionValues[scope.$index].resultType = ''
                this.currentItem.inspectionValues[scope.$index].resultValue = ''
            } else {
                console.log(scope.$index)
                let resultValue =
                    parseFloat(e) +
                    (Array.isArray(this.currentItem?.gap) && this.currentItem.gap.length > 0
                        ? parseFloat(this.currentItem.gap)
                        : 0)
                let resultType = 1
                if (
                    this.currentItem.decimalPlace != '' &&
                    this.currentItem.decimalPlace != null &&
                    this.currentItem.decimalPlace != undefined
                ) {
                    resultValue = resultValue.toFixed(
                        parseInt(this.currentItem.decimalPlace)
                    )
                } else {
                    resultValue = resultValue.toFixed(2)
                }

                if (
                    resultValue > parseFloat(this.currentItem.upperLimit) ||
                    resultValue < parseFloat(this.currentItem.lowerLimit)
                ) {
                    resultType = 0
                }
                console.log(resultValue)
                this.currentItem.inspectionValues[scope.$index].resultValue =
                    resultValue
                this.currentItem.inspectionValues[scope.$index].resultType =
                    resultType
            }

            console.log(this.currentItem.inspectionValues)
            this.judgeQualifid()
            this.$forceUpdate()
        },
        changeCheckoutValue(e, scope) {

            this.currentItem.inspectionValues[scope.$index].resultValue = e
            if (e === 'OK') {
                this.currentItem.qualifiedNum =this.currentItem.samplingAmount
                this.currentItem.inspectionValues[scope.$index].resultType = 1
            } else if (e === 'NA') {
                this.currentItem.inspectionValues[scope.$index].resultType = 2
                this.currentItem.qualifiedNum =0
            } else {
                this.currentItem.inspectionValues[scope.$index].resultType = 0
                this.currentItem.qualifiedNum =0
            }
            this.judgeQualifid(1)
        },
        // 判断检验结果是否合格
        judgeQualifid(n) {
            let sum = 0
            const resultValues = this.currentItem.inspectionValues.map( (item) => {
                sum += parseInt(item.inspectionValue)
                return item.resultValue
            }  )
            const resultTypes = this.currentItem.inspectionValues.map(
                (item) => item.resultType
            )
            console.log(resultTypes)
            console.log(resultValues,'resultValues************')
            if (resultValues?.length) {
                if (resultValues.includes('') || resultValues.includes(null)) {
                    this.comprehensiveResults = ''
                } else {
                    if (resultTypes.includes(0)) {
                        this.comprehensiveResults = '不合格'
                    } else if (resultTypes.includes(2)) {
                        this.comprehensiveResults = 'NA'
                    } else {
                        this.comprehensiveResults = '合格'
                    }
                }
            }
            if(!n){
                this.currentItem.qualifiedNum= sum
            }

        },
        getCheckoutResult(
            data,
            upperLimit,
            lowerLimit,
            gap,
            checkoutType,
            decimalPlace,
            samplingOne,
            samplingAmount,
            samRe,
            samAc
        ) {
            console.log('data',data)
            let checkoutValue = data ? data.split(',') : []
            let inspectionValues = []

            console.log(checkoutValue, 'checkoutValue=====')

            for (let i = 0; i < checkoutValue?.length; i++) {
                let inspectionValue = checkoutValue[i]
                    ? parseFloat(checkoutValue[i])
                    : null
                let resultValue = null
                let resultType = null
                if (checkoutType === '布尔型') {
                    resultValue = inspectionValue
                    resultType =
                        resultValue === 'OK' ? 1 : resultValue === 'NA' ? 2 : 0
                } else {
                    resultValue = checkoutValue[i]
                        ? parseFloat(checkoutValue[i]) +
                          (gap && gap?.length > 0 ? parseFloat(gap) : 0)
                        : null
                    if (
                        decimalPlace != '' &&
                        decimalPlace != null &&
                        decimalPlace != undefined
                    ) {
                        resultValue = resultValue
                            ? resultValue.toFixed(parseInt(decimalPlace))
                            : resultValue
                    } else {
                        resultValue = resultValue
                            ? resultValue.toFixed(2)
                            : resultValue
                    }

                    if (
                        resultValue > parseFloat(upperLimit) ||
                        resultValue < parseFloat(lowerLimit)
                    ) {
                        resultType = 0
                    }
                    if (
                        (resultValue < parseFloat(upperLimit) ||
                            resultValue == parseFloat(upperLimit)) &&
                        (resultValue > parseFloat(lowerLimit) ||
                            resultValue == parseFloat(lowerLimit))
                    ) {
                        resultType = 1
                    }
                }
                inspectionValues.push({
                    inspectionValue,
                    resultValue,
                    resultType,
                })
            }
            console.log(inspectionValues, 'inspectionValues=====')
            const resultTypes = inspectionValues.map((item) => item.resultType)
            if (checkoutValue.includes('')) {
                return ''
            }
            if (checkoutType === '布尔型' && checkoutValue?.length > 0) {
                if (samplingOne === 'GB/T2828.1-2012') {
                    let tempValue =
                        parseInt(samplingAmount) - parseInt(checkoutValue[0])
                    return parseInt(tempValue) > parseInt(samRe) ||
                        parseInt(tempValue) === parseInt(samRe)
                        ? 0
                        : 1
                } else if (samplingOne === 'GB/T2828.2-2008') {
                    let tempValue =
                        parseInt(samplingAmount) - parseInt(checkoutValue[0])
                    return parseInt(tempValue) > parseInt(samAc) ? 0 : 1
                } else {
                    return checkoutValue == 'OK'
                        ? 1
                        : checkoutValue == 'NA'
                        ? 2
                        : 0
                }
            }
            if (resultTypes?.length) {
                if (resultTypes.includes(0)) {
                    return 0
                } else {
                    return 1
                }
            }
        },
        formatTargetValueTo(targetValue) {
            if (
                Object.prototype.toString.call(targetValue) !==
                '[object String]'
            ) {
                return ''
            }
            return targetValue.replace(/&lt;|&gt;|&amp;/g, function (match) {
                return {
                    '&lt;': '<',
                    '&gt;': '>',
                    '&amp;': '&',
                }[match]
            })
        },
        formatTargetValueForward(targetValue) {
            if (
                Object.prototype.toString.call(targetValue) !==
                '[object String]'
            ) {
                return ''
            }
            return targetValue.replace(/<|>|&/g, function (match) {
                return {
                    '<': '&lt;',
                    '>': '&gt;',
                    '&': '&amp;',
                }[match]
            })
        },
        getIncomingDetail(id) {
            getIncomingDetail(id).then((response) => {
                let viewModel = response.data
                this.inspectionFlawList = response.data.inspectionFlawList
                viewModel.destroyAmount = viewModel.destroyAmount
                    ? viewModel.destroyAmount
                    : 0
                viewModel.outerPacking = viewModel.outerPacking
                    ? viewModel.outerPacking
                    : '0'
                viewModel.inspectionRohs = viewModel.inspectionRohs
                    ? viewModel.inspectionRohs
                    : '0'

                this.viewModel = response.data
                this.viewModel.inspectionCoa = viewModel.inspectionCoa ? viewModel.inspectionCoa : '2'
                this.viewModel.trialInvestment= viewModel.trialInvestment ? viewModel.trialInvestment : '2'



                let samplingAmount = 0
                //是否是复用检验值的单子 0:否1:是
                this.isReuse = response.data.isReuse
                let typeList = response.data.classList
                this.CleanTypeList = JSON.parse(JSON.stringify(response.data.classList))
                console.log(this.CleanTypeList,'取值时的CleanTypeList')
                typeList.forEach((io) => {
                    // io.comprehensiveResults = ''
                    // io.inspectorName = null
                    io.targetValue = this.formatTargetValueTo(io.targetValue)
                    if (io.inspector) {
                        /*  初始化不做校验获取检验结果
                        io.checkoutResult = this.getCheckoutResult(
                            io.checkoutValue,
                            io.upperLimit,
                            io.lowerLimit,
                            io.gap,
                            io.checkoutType,
                            io.decimalPlace,
                            io.samplingOne,
                            io.samplingAmount,
                            io.samRe,
                            io.samAc
                        )
                        */
                    }
                    if (io.samplingAmount) {
                        if (parseFloat(io.samplingAmount) > samplingAmount) {
                            samplingAmount = io.samplingAmount
                        }
                    }
                    if (io.checkoutType === '布尔型') {
                        io['value' + 0] = io.checkoutValue
                    } else {
                        for (let i = 0; i < io.samplingAmount; i++) {
                            let values = io.checkoutValue
                                ? io.checkoutValue.split(',')
                                : []
                            io['value' + i] = values[i]
                        }
                    }
                })
                console.log(typeList, 'typeList========')
                this.typeList = typeList
                // let tableHeader = []
                // for (let i = 0; i < 20; i++) {
                //     tableHeader.push('检验值' + (i + 1))
                // }
                // this.tableHeader = tableHeader
                this.loading = false
                // this.viewModel.exempted = '1'

                // 判定是否免检或试验料，满足一个则合格
                if ( viewModel.exempted === '1' || viewModel.experimentMaterial === '1' ) this.viewModel.decideResult = 1
                this.rebuildResult()
                // this.caculateAsyncDefect()
            }).finally(e=>{
                this.geFileByBizlist(this.id)
            })
        },
        getFlowByMaterialCode(code) {
            getFlowByMaterialCode({ code }).then((response) => {})
        },
        supplierDataCallback(row) {
            this.viewModel.supplierNo = row.supplierNo
            this.viewModel.supplierType = row.supplierType
        },
        materialDataCallback(row) {
            this.viewModel.materialNo = row.materialNo
            this.viewModel.materialType = row.materialType
            this.viewModel.maturity = row.maturity
            this.viewModel.materialTypeName = row.materialTypeName
        },
        closeTab() {
            this.$router.push({ path: '/inspect/incoming' })
        },
        effectDateChange(e, scope) {
            if (parseInt(e) > 0) {
                this.typeList[scope.$index].endDate = this.getNewDay(
                    scope.row.approvalTime,
                    e
                )
            }
        },
        getNewDay(dateTemp, days) {
            var dateTemp = dateTemp.split('-')
            //转换为MM-DD-YYYY格式
            var nDate = new Date(
                dateTemp[1] + '-' + dateTemp[2] + '-' + dateTemp[0]
            )
            var millSeconds = Math.abs(nDate) + days * 24 * 60 * 60 * 1000
            var rDate = new Date(millSeconds)
            var year = rDate.getFullYear()
            var month = rDate.getMonth() + 1
            if (month < 10) month = '0' + month
            var date = rDate.getDate()
            if (date < 10) date = '0' + date
            return year + '-' + month + '-' + date
        },
        changeCollapse(index) {
            const leftEls = this.$refs['itemTable'].$el.querySelectorAll(
                '.el-table__fixed .el-table__fixed-body-wrapper tbody tr'
            )[index]
            const rightEls = this.$refs['itemTable'].$el.querySelectorAll(
                '.el-table__fixed-right .el-table__fixed-body-wrapper tbody tr'
            )[index]
            const targetRow = this.$refs['itemTable'].$el.querySelectorAll(
                '.el-table__body-wrapper tbody tr'
            )[index]

            let setFixedRowHeight = setInterval(() => {
                const height = targetRow.getBoundingClientRect().height
                if (leftEls) {
                    leftEls.style.height = `${height}px`
                }
                if (rightEls) {
                    rightEls.style.height = `${height}px`
                }
            }, 10)
            setTimeout(() => {
                if (setFixedRowHeight) {
                    clearInterval(setFixedRowHeight)
                }
            }, 1000)
        },
        itemFileChange(e, index) {
            this.changeCollapse(index)
            let ids = e.map((item) => item.id)
            if (ids.length) {
                this.currentItem.fileId = ids.join(',')
            }
        },
        fileChange(e, index) {
            this.changeCollapse(index)
            console.log(e)
        },
        drawerClose() {
            this.comprehensiveResults = ''
            this.drawer = false
          this.hasMore = true
          this.displayedCheckoutList=[]
          this.currentItem.checkoutList=[]
          this.page=1
          this.pageSize=200
          this.differenceRepairSheet[this.currentItem.id] = false
        },
        /** 查询字典类型列表 */
        getList() {
            getNoticeList(this.queryParams).then((response) => {
                if (response.code == 200 && response.rows) {
                    //   this.typeList = response.rows;
                    this.total = response.total
                    this.loading = false
                }
            })
        },
        // 取消按钮
        cancel() {
            this.open = false
            this.reset()

        },
        // 表单重置
        reset() {
            this.form = {
                dictId: undefined,
                dictName: undefined,
                dictType: undefined,
                status: '0',
                remark: undefined,
            }
            this.resetForm('form')
        },
        /** 搜索按钮操作 */
        handleQuery() {
            this.queryParams.pageNum = 1
            this.getList()
        },
        /** 重置按钮操作 */
        resetQuery() {
            this.dateRange = []
            this.resetForm('queryForm')
            this.handleQuery()
        },
        /** 新增按钮操作 */
        handleAdd() {
            this.typeList.push({})
        },
        tableRowClassName({ row, rowIndex }) {
            if (row.isHighLight === true) {
                return 'rowHighLight' //若isHighLight为true，则使用“rowHighLight”样式
            } else {
                return ''
            }
        },
        // 多选框选中数据
        handleSelectionChange(selection) {
            this.ids = selection.map((item) => item.id)
            this.typeList.forEach((io, index) => {
                if (this.ids.includes(io.id)) {
                    io.isHighLight = true
                } else {
                    io.isHighLight = false
                }
            })
            this.single = selection.length != 1
            this.multiple = !selection.length
        },
        handleSelectTemplate() {
            this.templateVisible = true
        },
        baseProcess() {
            if (
                this.viewModel.amendBatch &&
                parseInt(this.viewModel.amendBatch) > 0
            ) {
                if (
                    parseInt(this.viewModel.destroyAmount) >
                    parseInt(this.viewModel.amendBatch)
                ) {
                    this.$modal.msgError('破坏性物料数量不能大于修正批数量!')
                    return
                }
            } else {
                if (
                    this.viewModel.batchAmount &&
                    parseInt(this.viewModel.batchAmount) > 0
                ) {
                    if (
                        parseInt(this.viewModel.destroyAmount) >
                        parseInt(this.viewModel.batchAmount)
                    ) {
                        this.$modal.msgError('破坏性物料数量不能大于原批数量!')
                        return
                    }
                }
            }
            this.$refs['resultForm'].validate((valid) => {
                if (valid) {
                    this.loading = true
                    let typeList = [...this.typeList]
                    typeList.forEach((io) => {
                        io.targetValue = this.formatTargetValueForward(
                            io.targetValue
                        )
                    })
                    console.log(typeList)
                    // 如果没有结果的话 重新判断一次结果
                    if(!(this.viewModel.decideResult=="0" || this.viewModel.decideResult==1)){
                         this.rebuildResult() 
                    }
                    for (const iterator of this.inspectionFlawList) {
                        for (const key in this.Obj) {
                            if (Object.hasOwnProperty.call(this.Obj, key)) {
                                if(iterator.id == key){
                                    iterator['samReCountCr'] = this.Obj[key].samReCountCr
                                    iterator['samReCountMa'] = this.Obj[key].samReCountMa
                                    iterator['samReCountMi'] = this.Obj[key].samReCountMi
                                }
                            }
                        }
                    }
                    let submitData = {
                        ...this.viewModel,
                        classList: typeList,
                    }
                    // 还是没有结果 弹出提示
                    if(!(submitData.decideResult=="0" || submitData.decideResult==1)){
                        this.$message("结果异常，请检查检验项或重新选择COA状态")
                        this.loading = false
                        return false
                    }
                    console.log(this.usedTypes)
                    localStorage.setItem('usedTypes',JSON.stringify(this.usedTypes))
                    let Tkeys = Object.keys(this.usedTypes)
                    let sheetKey = Tkeys.map(val => {
                        return val.split(',')[1]
                    })
                    for (const iterator of typeList) {
                        for (const item of sheetKey) {
                          if(iterator.id == item){
                                iterator.dataType = 1
                            }
                        }
                    }

                    console.log(JSON.stringify(submitData))
                    addIncoming(submitData)
                        .then((response) => {
                            if (response.code == 200) {
                                this.$modal.msgSuccess('提交成功!')
                                this.$router.push({ path: '/inspect/incoming' })
                            } else {
                                this.$modal.msgError(response.msg)
                            }
                        })
                        .catch((error) => {
                            this.loading = false
                        })
                } else {
                    console.log('error submit!!')
                    return false
                }
            })
        },
        submitTime() {
            this.expireForm.id = this.viewModel.extraId
            updateValidityDate(this.expireForm)
                .then((response) => {
                    if (response.code == 200) {
                        this.baseProcess()
                    } else {
                        this.$modal.msgError(response.msg)
                    }
                })
                .catch((error) => {
                    this.loading = false
                })
        },
        /** 提交按钮 */
        submitForm: function () {
            // if (this.viewModel.dataSource === '库存') {
            //     this.expireTimeOpen = true
            //     return
            // }
            // if(this.viewModel.inspectionCoa!=2 && this.coaBizTypeList.length==0){
            //     this.$message.error("请上传COA报告照片")
            //     return
            // }

            this.baseProcess()
        },
        saveStorage: function () {
            console.log('提交表单',this.viewModel)
            // if(viewModel.inspectionCoa!=2 && this.coaBizTypeList.length>0){
            //     this.$message.error("请上传COA报告照片")
            //     return
            // }

            this.$refs['resultForm'].validate((valid) => {
                if (valid) {
                    this.loading = true
                    let typeList = [...this.typeList]
                    typeList.forEach((io) => {
                        io.targetValue = this.formatTargetValueForward(
                            io.targetValue
                        )
                    })
                    console.log(typeList)
                    console.log(this.usedTypes)
                    localStorage.setItem('usedTypes',JSON.stringify(this.usedTypes))
                    let Tkeys = Object.keys(this.usedTypes)
                    let sheetKey = Tkeys.map(val => {
                        return val.split(',')[1]
                    })
                    for (const iterator of typeList) {
                        for (const item of sheetKey) {
                          if(iterator.id == item){
                                iterator.dataType = 1
                            }
                        }
                    }
                    for (const iterator of this.inspectionFlawList) {
                        for (const key in this.Obj) {
                            if (Object.hasOwnProperty.call(this.Obj, key)) {
                                if(iterator.id == key){
                                    iterator['samReCountCr'] = this.Obj[key].samReCountCr
                                    iterator['samReCountMa'] = this.Obj[key].samReCountMa
                                    iterator['samReCountMi'] = this.Obj[key].samReCountMi
                                }
                            }
                        }
                    }
                    let submitData = {
                        ...this.viewModel,
                        classList: typeList,
                    }
                    console.log(JSON.stringify(submitData))
                    updateIncoming(submitData)
                        .then((response) => {
                            if (response.code == 200) {
                                this.$modal.msgSuccess('提交成功!')
                                this.$router.push({ path: '/inspect/incoming' })
                            } else {
                                this.$modal.msgError(response.msg)
                            }
                        })
                        .catch((error) => {
                            this.loading = false
                        })
                } else {
                    console.log('error submit!!')
                    return false
                }
            })
        },

        /** 发起检验提交 */
        submitAddForm: function () {
            this.$modal.msgSuccess('发起成功!')
            this.addInspection = false
        },

        /** 删除按钮操作 */
        handleDelete(row) {
            if (this.typeList.length === 1) {
                this.$modal.msgWarning('请至少保留一条检验项!')
                return
            }
            this.typeList.splice(row.$index, 1)
        },
        /** 查看按钮操作 */
        handleView(row) {
            this.form = row
            this.viewInspectionExemption = true
            //   if(row.hasRead == 0){
            //     readNotice(row.noticeId).then(res=>{
            //       if(res.code == 200){
            //         this.handleQuery()
            //       }
            //     })
            //   }
        },
        // 同步编码值
        handleSyncCode() {

            var checkoutList=[]
            var samplingAmount=0
            var samplingLength = 0
            if(this.overindex>-1){
                checkoutList= this.CleanTypeList[this.overindex].checkoutList
                console.log(checkoutList,'上一个打开的checkoutlist')
                let currentSampleCodeList=Array.from(new Set(checkoutList.map(it => it.sampleCode)))
                console.log(currentSampleCodeList,'以及他的样本编号')
                let maxSampleCodeList = null
                for (let i = 0; i < this.typeList.length; i++) {
                    var item=this.typeList[i]
                    var copyItem = this.CleanTypeList[i]
                    console.log(item)

                    // 如果是计量的并且检验值为不为null
                    if(item.checkoutTypeCopy=="计量" && item.checkoutResult!==null){
                        if (copyItem.samplingAmount>=samplingAmount && copyItem.checkoutList.length>samplingLength) {
                            console.log(copyItem,'检查最长的样本量')
                            samplingAmount=copyItem.samplingAmount
                            maxSampleCodeList = copyItem.checkoutList
                            samplingLength = copyItem.checkoutList.length
                        }
                    }
                }
                maxSampleCodeList = Array.from(new Set(maxSampleCodeList.map(it => it.sampleCode)))
                console.log(maxSampleCodeList,'与最长的合并后')
                currentSampleCodeList = currentSampleCodeList.concat(maxSampleCodeList.splice(currentSampleCodeList.length))
                return currentSampleCodeList
            }else{
                // 循环查检验项
                for (let i = 0; i < this.CleanTypeList.length; i++) {
                    var item=this.CleanTypeList[i]
                    // 如果是计量的并且检验值为不为null
                    if(item.checkoutTypeCopy=="计量" && item.checkoutResult!==null){
                        if (item.samplingAmount>=samplingAmount && item.checkoutList.length>samplingLength) {
                            console.log(item,'第一次打开时最后一个最长的')
                                samplingAmount=item.samplingAmount
                                checkoutList=item.checkoutList
                                samplingLength = item.checkoutList.length
                        }
                    }
                }
            }
            var sampleCodeList=Array.from(new Set(checkoutList.map(it => it.sampleCode)))
            console.log(sampleCodeList,'第一次打开时最长的样本编号')
           
            return sampleCodeList
        },
        getData(scope) {
            // 临时保存
            this.tempScope = scope
            this.incomingItemDialogvisible = true
            this.incomingItemDialogScope = scope.row
        },
        /** 编辑按钮操作 */
        handleEdit(scope,boolean,boolean2) {
            this.applicationStatus = boolean2 === false ? boolean2 : boolean
            console.log(scope,'编辑时数据')
            let currentItem = JSON.parse(JSON.stringify(scope.row))
            currentItem.flawList = currentItem.flawList
                ? currentItem.flawList
                : []
            this.comprehensiveResults = ''
            if (
                currentItem.inspectorName === null ||
                currentItem.inspectorName === undefined ||
                currentItem.inspectorName === ''
            ) {
                currentItem.inspectorName = this.name
                currentItem.inspector = this.userId
            } else {
                this.currentItem.inspectorName = currentItem.inspectorName
                this.currentItem.inspector = currentItem.inspector
            }

            console.log(currentItem, 'currentItem')
            currentItem.index = scope.$index
            /*  弃用 currentItem.checkoutValue 字段， 改用 checkoutList 保存 */
            let checkoutValue = currentItem.checkoutValue
                ? currentItem.checkoutValue.split(',')
                :  currentItem.checkoutList?.map(i=>i.checkoutValue)

            let resultValue = void 0;
            let result = void 0;
            if(!currentItem.resultValue) resultValue = currentItem.checkoutList?.map(i=>i.resultValue)
            if(!currentItem.result) result = currentItem.checkoutList?.map(i=>i.result)

            console.log('点击班级',currentItem.checkoutList)
            console.log('点击班级',resultValue,result)
            let inspectionValues = []
            if (scope.row.checkoutType === '布尔型') for (let i = 0; i < currentItem.samplingAmount; i++) {
                let inspectionValue = checkoutValue[i] ? checkoutValue[i] : ''
                console.log('inspectionValue-->>',inspectionValue,checkoutValue)

                let resultValue = resultValue??''
                let resultType = result??''
                if (scope.row.checkoutType === '布尔型') {
                    if (scope.row.samplingOne === 'GB/T2828.1-2012') {
                        console.log('进入GB/T2828.1-2012判定')
                        resultValue =
                            parseInt(scope.row.samplingAmount) -
                            parseInt(inspectionValue)
                        if (
                            inspectionValue === '' ||
                            inspectionValue === null ||
                            inspectionValue === undefined
                        ) {
                            console.log('null')
                            resultValue = null
                            resultType = null
                        } else if (
                            resultValue > parseInt(scope.row.samRe) ||
                            resultValue === parseInt(scope.row.samRe)
                        ) {
                            console.log('0')
                            resultType = 0
                        } else {
                            console.log('1')
                            resultType = 1
                        }
                        console.log('resultType',resultType,inspectionValue)
                    } else if (scope.row.samplingOne === 'GB/T2828.2-2008') {
                        console.log('进入GB/T2828.2-2008判定')
                        resultValue =
                            parseInt(scope.row.samplingAmount) -
                            parseInt(inspectionValue)
                        if (
                            inspectionValue === '' ||
                            inspectionValue === null ||
                            inspectionValue === undefined
                        ) {
                            resultValue = null
                            resultType = null
                        } else if (resultValue > parseInt(scope.row.samAc)) {
                            resultType = 0
                        } else {
                            resultType = 1
                        }
                    } else {
                        console.log('其他',resultValue)
                        resultValue = inspectionValue
                        if (resultValue == '0') { // 'OK'
                            inspectionValue = 'OK'
                            resultType = 1
                        } else if (resultValue == '2') { // 'NA'
                            inspectionValue = 'NA'
                            resultType = 2
                        } else if (resultValue == '1') { // 'NG'
                            inspectionValue = 'NG'
                            resultType = 0
                        } else {
                            resultType = null
                        }
                    }
                } else { // '数值'
                    return
                    resultValue = checkoutValue[i]
                        ? parseFloat(
                              checkoutValue[i] && checkoutValue[i].length > 0
                                  ? parseFloat(checkoutValue[i])
                                  : checkoutValue[i] + currentItem.gap &&
                                    currentItem.gap.length > 0
                                  ? parseFloat(currentItem.gap)
                                  : currentItem.gap
                          )
                        : null
                    if (
                        currentItem.decimalPlace != '' &&
                        currentItem.decimalPlace != null &&
                        currentItem.decimalPlace != undefined
                    ) {
                        resultValue = resultValue
                            ? resultValue.toFixed(
                                  parseInt(currentItem.decimalPlace)
                              )
                            : resultValue
                    } else {
                        resultValue = resultValue
                            ? resultValue.toFixed(2)
                            : resultValue
                    }
                    console.log('判断校验',resultValue,currentItem.upperLimit,currentItem.lowerLimit)
                    if (
                        resultValue > parseFloat(currentItem.upperLimit) ||
                        resultValue < parseFloat(currentItem.lowerLimit)
                    ) {
                        resultType = 0
                        if (checkoutValue.length > 0) {
                            this.comprehensiveResults = '不合格'
                        }
                    }
                    if (
                        (resultValue < parseFloat(currentItem.upperLimit) ||
                            resultValue ==
                                parseFloat(currentItem.upperLimit)) &&
                        (resultValue > parseFloat(currentItem.lowerLimit) ||
                            resultValue == parseFloat(currentItem.lowerLimit))
                    ) {
                        resultType = 1
                        if (checkoutValue.length > 0) {
                            this.comprehensiveResults = '合格'
                        }
                    }
                }

                if (scope.row.checkoutType === '布尔型' && i > 0) {
                    continue
                }
                console.log('结果',checkoutValue[i])
                inspectionValues.push({
                    inspectionValue,
                    resultValue,
                    resultType,
                })
                console.log(inspectionValues)
            }
            if (scope.row.checkoutType === '数值'){
                if(Array.isArray(scope.row.checkoutList)) scope.row.checkoutList.forEach((item,i)=>{
                    let inspectionValue = item.checkoutValue ?? ''

                let resultValue = null
                let resultType = null
                    resultValue = checkoutValue[i]
                        ? parseFloat(
                              checkoutValue[i] && checkoutValue[i].length > 0
                                  ? parseFloat(checkoutValue[i])
                                  : checkoutValue[i] + currentItem.gap &&
                                    currentItem.gap.length > 0
                                  ? parseFloat(currentItem.gap)
                                  : currentItem.gap
                          )
                        : null
                    if (
                        currentItem.decimalPlace != '' &&
                        currentItem.decimalPlace != null &&
                        currentItem.decimalPlace != undefined
                    ) {
                        resultValue = resultValue
                            ? resultValue.toFixed(
                                  parseInt(currentItem.decimalPlace)
                              )
                            : resultValue
                    } else {
                        resultValue = resultValue
                            ? resultValue.toFixed(2)
                            : resultValue
                    }
                    console.log('判断校验',resultValue,currentItem.upperLimit,currentItem.lowerLimit)
                    if (
                        resultValue > parseFloat(currentItem.upperLimit) ||
                        resultValue < parseFloat(currentItem.lowerLimit)
                    ) {
                        resultType = 0
                        if (checkoutValue.length > 0) {
                            this.comprehensiveResults = '不合格'
                        }
                    }
                    if (
                        (resultValue < parseFloat(currentItem.upperLimit) ||
                            resultValue ==
                                parseFloat(currentItem.upperLimit)) &&
                        (resultValue > parseFloat(currentItem.lowerLimit) ||
                            resultValue == parseFloat(currentItem.lowerLimit))
                    ) {
                        resultType = 1
                        if (checkoutValue.length > 0) {
                            this.comprehensiveResults = '合格'
                        }
                    }
                    inspectionValues.push({
                        inspectionValue,
                        resultValue,
                        resultType,

                    })
                })
            }
            console.log(inspectionValues)
            console.log('currentItem.checkoutResult',currentItem.checkoutResult)

            if (currentItem.checkoutResult == '1') {
                this.comprehensiveResults = '合格'
            } else
            if (currentItem.checkoutResult == '2') {
                this.comprehensiveResults = 'NA'
            }else
            if (currentItem.checkoutResult == '0') {
                this.comprehensiveResults = '不合格'
            }else
            if (currentItem.checkoutResult === '') {
                this.comprehensiveResults = ''
            }else
            if (checkoutValue.includes('') || checkoutValue.includes(null)) {
                this.comprehensiveResults = ''
            }

            // 样本检验项
        if( scope.row.checkoutType === '数值'){
            let checkoutList = [];
            if(Array.isArray(currentItem.checkoutList) && currentItem.checkoutList.length > 0){
                debugger
                let sampleCodeEnum = {}
                let samplingSort = []
                currentItem.checkoutList.forEach(i=>{
                    if(i.sampleCode) {
                        if(samplingSort.indexOf(i.sampleCode) == -1) samplingSort.push(i.sampleCode) 
                        if(Array.isArray(sampleCodeEnum[i.sampleCode])){
                            sampleCodeEnum[i.sampleCode].push(i)
                        }else {
                            sampleCodeEnum[i.sampleCode] = [i]
                        }
                    }
                })
                console.log(samplingSort,sampleCodeEnum,'保证顺序1')
                for (const iterator of samplingSort) {
                    for (const key in sampleCodeEnum) {
                        if (Object.hasOwnProperty.call(sampleCodeEnum, key)) {
                            if(key === iterator){
                                checkoutList.push({
                                    sampleCode: key,
                                    checkoutItemList: sampleCodeEnum[key]
                                })
                            }
                        }
                    }
                }
                console.log(checkoutList,'保证顺序2')
                if(checkoutList.length != currentItem.samplingAmount){
                    var misslength=currentItem.samplingAmount - checkoutList.length
                    let applyArr=[]   
                    for (let index = 0; index < misslength; index++) {
                        applyArr.push({
                            sampleCode:(checkoutList.length+1),
                            checkoutItemList: [new CheckoutItem()]
                        })    
                    }
                    console.log('拼接数组',applyArr)
                    checkoutList = checkoutList.concat(applyArr)
                     
                    console.log('拼接数组',checkoutList)
                }
            }else {
                for (let i = 0; i < currentItem.samplingAmount; i++) {
                    checkoutList.push(
                        {
                            sampleCode:(i+1),
                            checkoutItemList: [new CheckoutItem()]
                        }
                    )
                }
            }
            // 复制 检验标准 上限值 下限值

            currentItem.targetValueCopy=currentItem.targetValue
            currentItem.lowerLimitCopy=currentItem.lowerLimit
            currentItem.upperLimitCopy=currentItem.upperLimit


            var codelist=this.handleSyncCode()
            console.log(codelist,checkoutList,"999999999999999999999999999999999")

            currentItem.singleSample = currentItem.singleSample ? currentItem.singleSample : '2'

            currentItem.checkoutList = checkoutList.map((item,i)=>{
                var sampleCode=i+1
                if(codelist.length==0){
                      sampleCode=item.sampleCode?item.sampleCode:sampleCode
                }else{
                    sampleCode=codelist[i]?codelist[i] :(i+1)
                }
               
              return {
                ...item,
                singleValue:item.checkoutItemList[0].singleValue,
                singleResult:item.checkoutItemList[0].singleResult,
                sampleCode:String(sampleCode)
              }
            })

        }

            // 保存样品检验项 结束

            currentItem.flawProjectName = scope.row.flawProjectName
                ? scope.row.flawProjectName.split(';')
                : scope.row.flawProjectName
            currentItem.inspectionValues = inspectionValues
            console.log(currentItem.inspectionValues)
            this.currentItem = currentItem
            console.log('currentItem',currentItem)
            this.rowId = scope.row.id
            this.getItemFileByIdForItem(this.rowId)
            this.drawer = boolean
            // this.judgeQualifid()
            this.loadMore();
            if(currentItem.singleSample == 2){
                this.changesingleSample(2)
            }
        },
        approvalCallback(names, ids) {
            this.viewModel.auditName = names
            this.viewModel.auditId = ids
            this.$refs['resultForm'].validate((valid) => {
                if (valid) {
                    this.loading = true
                    let typeList = [...this.typeList]
                    console.log(typeList)
                    let submitData = {
                        ...this.viewModel,
                        classList: typeList,
                    }
                    console.log(JSON.stringify(submitData))
                    approvalIncoming(submitData)
                        .then((response) => {
                            if (response.code == 200) {
                                this.$modal.msgSuccess('提交成功!')
                                this.$router.push({ path: '/inspect/incoming' })
                            } else {
                                this.$modal.msgError(response.msg)
                            }
                        })
                        .catch((error) => {
                            this.loading = false
                        })
                } else {
                    console.log('error submit!!')
                    return false
                }
            })
        },
        /** 关闭抽屉操作 */
        handleClose(row) {
            this.drawer = false
          this.displayedCheckoutList=[]
          this.currentItem.checkoutList=[]
          this.hasMore = true
          this.page=1
          this.pageSize=200
          this.differenceRepairSheet[this.currentItem.id] = false
        },
        /** 导出按钮操作 */
        handleExport() {
            this.download(
                'system/dict/type/export',
                {
                    ...this.queryParams,
                },
                `type_${new Date().getTime()}.xlsx`
            )
        },
        /** 刷新缓存按钮操作 */
        handleRefreshCache() {
            refreshCache().then(() => {
                this.$modal.msgSuccess('刷新成功')
            })
        },

        // 新增样本检验项
        handleAddCheck(record,n){
            console.log('检验项',record)
            // Array.isArray(record?.checkoutItemList) && record.checkoutItemList.push(new CheckoutItem())
            var num = n ? n : 1
            if (Array.isArray(record?.checkoutItemList)) {
                for (var i = 0; i < num; i++) {
                    record.checkoutItemList.push(new CheckoutItem())
                }
            }
        },

        changesingleSample(e){
            if(e==2){
                this.judgeQualifidCheckoutIItem()
            }else{
                this.compreseditem()
}
            this.$forceUpdate()
        },
        targetValueChange(e){
            var lwTolerance= this.currentItem.lwTolerance
            var upTolerance= this.currentItem.upTolerance
            var targetValue=this.currentItem.targetValue
            this.currentItem.lowerLimit=parseFloat(targetValue)-parseFloat(upTolerance)
            this.currentItem.upperLimit=parseFloat(lwTolerance)+parseFloat(targetValue)
            this.currentItem.targetValue=parseFloat(targetValue)
            this.$forceUpdate()
        },
        // 校验样品检验项结果值
        acceptChangeItem(e, scope,itemList,indexT) {
            if (!e) {
                scope.row.result = ''
                scope.row.resultValue = ''
            } else {
                let resultValue = parseFloat(e)
                let resultType = ''
                let lowerLimit = this.currentItem.lowerLimit
                let upperLimit = this.currentItem.upperLimit
                let targetValue = this.currentItem.targetValue
                // 包含 传 1；不包含 传 0
                let includeMin = this.currentItem.lowerLimitContains==='0'?false:true
                let includeMax = this.currentItem.upperLimitContains==='0'?false:true
                console.log('---->',this.currentItem.lowerLimit,this.currentItem.upperLimit)
                if((parseFloat(lowerLimit) || parseFloat(lowerLimit)==0) && (parseFloat(upperLimit) || parseFloat(upperLimit)==0) ){
                    // 当上限值或下限值都有值
                    resultType =this.isQualified(resultValue, lowerLimit, upperLimit, includeMin, includeMax)? 1:0

                }else if((parseFloat(lowerLimit) || parseFloat(lowerLimit)==0) || (parseFloat(upperLimit) || parseFloat(upperLimit)==0)){
                    //  下限值只有一个有值
                    if(parseFloat(lowerLimit) || parseFloat(lowerLimit)==0) {
                        if (includeMin) {
                            resultType = parseFloat(lowerLimit)<= resultValue ? 1:0
                        }else{
                            resultType = parseFloat(lowerLimit)< resultValue ? 1:0
                        }
                    }
                    //  上限值只有一个有值
                    if(parseFloat(upperLimit) || parseFloat(upperLimit)==0) {
                        if (includeMax) {
                            resultType = resultValue <= parseFloat(upperLimit) ? 1:0
                        }else{
                            resultType = resultValue < parseFloat(upperLimit) ? 1:0
                        }
                    }
                }else {
                    // 上下限都没值，则根据目标值判断
                    if(parseFloat(targetValue)){
                        resultType = resultValue == parseFloat(targetValue) ? 1:0
                    }else {
                        resultType = 1
                    }
                }

                scope.row.resultValue = resultValue
                scope.row.result = resultType
            }


            if(this.currentItem.singleSample==2){
                this.judgeQualifidCheckoutIItem()

            }else{
                this.compreseditem()
            }
            this.$forceUpdate()
        },
        // 通过 检验值、最小值、最大值、是否包含最小、是否包含最大 5个参数判断是否合格
        isQualified(value, minValue, maxValue, includeMin, includeMax) {  
            
            if (includeMin && includeMax) {  
                // 有上下包含值
                return parseFloat(value) >= parseFloat(minValue) && parseFloat(value) <= parseFloat(maxValue);  
            } else if (includeMin) {  
                return parseFloat(value) >= parseFloat(minValue) && parseFloat(value) <  parseFloat(maxValue);  
            } else if (includeMax) {  
                return parseFloat(value) >  parseFloat(minValue) && parseFloat(value) <= parseFloat(maxValue);  
            } else {  
                // 无上下包含值
                return parseFloat(value) > parseFloat(minValue) && parseFloat(value) < parseFloat(maxValue);  
            }  
             
        } ,
        //均值--判断每个小项
        compreseditem(){
            let lowerLimit = this.currentItem.lowerLimit
            let upperLimit = this.currentItem.upperLimit
            let targetValue = this.currentItem.targetValue
            // 包含 传 1；不包含 传 0
            let includeMin = this.currentItem.lowerLimitContains==='0'?false:true
            let includeMax = this.currentItem.upperLimitContains==='0'?false:true
            // 大项列表
            var checkoutList=  this.currentItem.checkoutList
            for (let i = 0; i < checkoutList.length; i++) {
                    // 1是否填写完1小项
                    var isoveritem=true
                    // 平均数
                    var resultValue=0
                    // 小项列表
                    var checkoutItemList=checkoutList[i].checkoutItemList
                    for (let j = 0; j < checkoutItemList.length; j++) {
                        if(!checkoutItemList[j]?.checkoutValue){
                            isoveritem=false
                            break
                        }else{
                            resultValue+=parseFloat(checkoutItemList[j].checkoutValue)
                        }

                    }
                    let resultType = ''//1合格 0 不合格
                    // 2填写完一小项
                    if(isoveritem){
                        //    提前进行四舍五入
                        var decimalPlace=this.currentItem.decimalPlace?this.currentItem.decimalPlace:2
                        resultValue=(resultValue/checkoutItemList.length).toFixed(decimalPlace)
                        if((parseFloat(lowerLimit) || parseFloat(lowerLimit)==0) && (parseFloat(upperLimit) || parseFloat(upperLimit)==0) ){
                            // 当上限值或下限值都有值
                            
                            resultType =this.isQualified(resultValue, lowerLimit, upperLimit, includeMin, includeMax)? 1:0

                        }else if((parseFloat(lowerLimit) || parseFloat(lowerLimit)==0) || (parseFloat(upperLimit) || parseFloat(upperLimit)==0)){
                           //  下限值只有一个有值
                            if(parseFloat(lowerLimit) || parseFloat(lowerLimit)==0) {
                                if (includeMin) {
                                    resultType = parseFloat(lowerLimit)<= resultValue ? 1:0
                                }else{
                                    resultType = parseFloat(lowerLimit)< resultValue ? 1:0
                                }
                            }
                            //  上限值只有一个有值
                            if(parseFloat(upperLimit) || parseFloat(upperLimit)==0) {
                                if (includeMax) {
                                    resultType = resultValue <= parseFloat(upperLimit) ? 1:0
                                }else{
                                    resultType = resultValue < parseFloat(upperLimit) ? 1:0
                                }
                            }
                        }else {
                            // 上下限都没值，则根据目标值判断
                            if(parseFloat(targetValue)){
                                resultType = resultValue == parseFloat(targetValue) ? '1':'0'
                            }else {
                                resultType = '1'
                            }
                        }
                            //小项判断 生成小项的结果
                        console.log(resultType,resultValue)
                        this.currentItem.checkoutList[i].singleResult=resultType//1合格 0 不合格
                        // var decimalPlace=this.currentItem.decimalPlace?this.currentItem.decimalPlace:2
                        this.currentItem.checkoutList[i].singleValue=resultValue 
                    }

            }
            this.compresed()
        },
        //大小值--判断每个小项
        compresedSizeitem(){

            // 大项列表
            var checkoutList=  this.currentItem.checkoutList
            for (let i = 0; i < checkoutList.length; i++) {
                    //
                    var hasfalse=true
                    let resultType = '1'//1合格 0 不合格
                    let resultValue=0
                    var results=[]//每个小项的结果
                    // 小项列表
                    var checkoutItemList=checkoutList[i].checkoutItemList
                    for (let j = 0; j < checkoutItemList.length; j++) {
                        resultValue+=parseFloat(checkoutItemList[j].checkoutValue)
                        if(checkoutItemList[j]?.result!=1){
                            resultType="0"
                            results.push('0')

                        }

                    }

                    // 2填写完一小项
                    if(hasfalse){
                        resultValue=resultValue/checkoutItemList.length
                        this.currentItem.checkoutList[i].singleResult=results.length>0?'0':'1'//1合格 0 不合格
                        var decimalPlace=this.currentItem.decimalPlace?this.currentItem.decimalPlace:2
                        this.currentItem.checkoutList[i].singleValue=resultValue.toFixed(decimalPlace)
                    }

            }
            // 合格数量
            this.currentItem.qualifiedNum=checkoutList.filter(item=>item.singleResult==1).length
        },
        // 均值--判断大项
      compresed() {
        //debugger;
            const resultValues = this.currentItem.checkoutList.map(i=>{
                //let arr = i.checkoutItemList.map(j=>j.resultValue)
                return i?.singleValue
            }).flat()

            Array.isArray(resultValues) && this.conputedAverageValFn(resultValues)
            //判断大项
            var checkoutList= this.currentItem.checkoutList
            var results=[]//每个小项的结果
            for (let index = 0; index < checkoutList.length; index++) {
                if(checkoutList[index].singleResult=='1'){
                    results.push('1')
                }
                if(checkoutList[index].singleResult=='0'){
                    results.push('0')
                }
            }
            // 合格数量
            this.currentItem.qualifiedNum=results.filter(item=>item==1).length
            // 表单没有填完时
            if(!(results.length==checkoutList.length && results.length>0)){
                this.comprehensiveResults = 'NA'
                return
            }
            // 表单填完时
            if(results.includes(void 0) || results.includes('')){
                this.comprehensiveResults = 'NA'
            }else{
                if (results.includes('0')) {
                    // 当不合格数量大于拒收数时，整体结果为不合格
                    if( parseInt(this.currentItem?.samRe) ){
                        console.log('拒收数',this.currentItem?.samRe)
                        const disResut =  results.filter(i=>i=='0').length
                        return this.comprehensiveResults = disResut >= parseInt(this.currentItem?.samRe) ? '不合格':'合格'
                    }
                    this.comprehensiveResults = '不合格'
                } else if (results.includes('2')) {
                    this.comprehensiveResults = 'NA'
                } else {
                    this.comprehensiveResults = '合格'
                }
            }
        },
        //最大最小-- 判断检验结果是否合格
        judgeQualifidCheckoutIItem() {
            this.compresedSizeitem()
            const resultValues = this.currentItem.checkoutList.map(i=>{
                //let arr = i.checkoutItemList.map(j=>j.resultValue)
                return i?.singleValue
            }).flat()
            const results = this.currentItem.checkoutList.map(i=>{
                const itemResults = i.checkoutItemList.map(j=>j.result)
                if(itemResults.includes(void 0) || itemResults.includes('')) return ""
                if(itemResults.includes('0') || itemResults.includes(0)) return 0
                return 1
            })
            // const resultValues = this.currentItem.inspectionValues.map(
            //     (item) => item.resultValue
            // )
            // const resultTypes = this.currentItem.inspectionValues.map(
            //     (item) => item.resultType
            // )

            Array.isArray(resultValues) && this.conputedAverageValFn(resultValues)
            if (resultValues?.length) {
                // if (resultValues.includes('') || resultValues.includes(null)) {
                //     this.comprehensiveResults = ''
                // }
                if(results.includes(void 0) || results.includes('')){
                    this.comprehensiveResults = 'NA'
                }else
                if (results.includes(0)) {
                    // 当不合格数量大于拒收数时，整体结果为不合格
                    if( parseInt(this.currentItem?.samRe) ){
                        console.log('拒收数',this.currentItem?.samRe)
                        const disResut =  results.filter(i=>i=='0').length
                        return this.comprehensiveResults =
                            disResut >= parseInt(this.currentItem?.samRe) ?
                            '不合格':'合格'
                    }
                    this.comprehensiveResults = '不合格'
                } else if (results.includes(2)) {
                    this.comprehensiveResults = 'NA'
                } else {
                    this.comprehensiveResults = '合格'
                }
            }
            this.$forceUpdate()

      },
        // 计算 最小、最大、均值、差值
        conputedAverageValFn(arr){
            const minimum = Math.min(...arr??0)
            const maximum = Math.max(...arr??0)
            const meanValue = arr.reduce((pre,cur)=>parseFloat(pre)+parseFloat(cur))/arr.length
            const rangeValue = maximum - minimum
            this.currentItem.minimum = minimum
            this.currentItem.maximum = maximum
            this.currentItem.meanValue =  meanValue.toFixed(this.currentItem.decimalPlace?this.currentItem.decimalPlace : 2 )
            this.currentItem.rangeValue = rangeValue.toFixed(this.currentItem.decimalPlace?this.currentItem.decimalPlace : 2 )
        },
        // 删除样本检验项
        handleCheckoutItemDel(row,tableList){
            if(Array.isArray(tableList) && tableList.length === 1) return this.$modal.msgWarning('样本检验项至少有一条数据')
            this.$modal.confirm(this.$t('organize.confirmDelete')).then(() => {
                tableList.splice(row.$index, 1)
                this.$modal.msgSuccess(this.$t('public.delSuc'))
                this.judgeQualifidCheckoutIItem();
            })
        },

        // 大缺陷远程搜索
        maxFlawNameRemoteFN(query){
            console.log('maxFlawNameRemoteFN',query)
            this.maxLoading = true;
            listAllMaxFlaw({ maxFlawName: query }).then((res)=>{
                if(res.code == 200 ){
                    this.maxFlawNameOptions = res.data
                }
            }).finally(()=>{
                this.maxLoading = false;
            })
        },
        minFlawNameRemoteFN(query,row){
            if(!row.maxFlawId) return this.$modal.msgWarning('请选择大缺陷')
            console.log('minFlawNameRemoteFN',query)
            this.minLoading = true;
            getMinFlawAll({ maxFlawId: row.maxFlawId, minFlawName: query }).then(res=>{
                if(res.code == 200 ){
                    this.minFlawNameOptions = res.data
                }
            }).finally(()=>{
                this.minLoading = false;
            })
        }
    },
}
</script>
<style lang="scss" scoped>
.load-more-container {
  bottom: 0;
  background-color: #fff;
  z-index: 1;
  padding: 10px;
  text-align: center;
}
::v-deep .el-card {
    padding-top: 20px;
    border: 0px;
    box-shadow: 0px 2px 6px 0px rgba(0, 0, 0, 0.08);
    border-radius: 4px;
    padding-bottom: 20px;
}
::v-deep .el-aside {
    padding: 0;
    margin-bottom: 0;
}
.content-style {
    border: 0px;
    box-shadow: 0px 2px 6px 0px rgba(0, 0, 0, 0.08);
    border-radius: 2px;
    background-color: white;
    margin-top: 10px;
}
::v-deep .el-button-group .selBtn {
    background: #fff;
    border: 1px solid #0b7be3;
    color: #0b7be3;
}
::v-deep .el-button-group .unselBtn {
    background: #fff;
    border: 1px solid #ededf2;
    color: #666666;
}
.header-left {
    float: left;
    font-size: 14px;
    font-family: PingFangSC-Semibold, PingFang SC;
    font-weight: 600;
    color: #333333;
    line-height: 40px;
    display: flex;

    align-items: center;
}
.header-right {
    float: right;
}
.container-header {
    float: left;
    width: 100%;
    border-bottom: 1px solid #ededf2;
    padding-left: 12px;
}
.container-table {
    float: left;
    margin-top: 6px;
    width: 100%;
    //   max-height: calc(100vh - 600px);
    overflow: auto;
}
.mb8 {
    float: left;
    margin-top: 6px;
    width: 100%;
}
.drawer-footer {
    display: flex;
    position: absolute;
    z-index: 9999;
    bottom: 4vh;
    justify-content: center;
    width: 100%;
}
.hign-line {
    position: relative;
    left: -8px;
    top: 14px;
    height: 12px;
    border-radius: 2px;
    border: 1px solid #0b7be3;
    float: left;
}
.drawer-close {
    background: #f7f8fa;
    border-color: #f7f8fa;
}
.submit-footer {
    height: 52px;
    background: #ffffff;
    box-shadow: 0px -5px 5px 0px rgba(0, 0, 0, 0.08);
    border-radius: 4px 4px 0px 0px;
    position: fixed;
    z-index: 9;
    bottom: 0px;
    width: 100%;
    left: 0px;
    display: flex;
    justify-content: center;
    align-items: center;
}
.samplingPercent {
    position: absolute;
    z-index: 9;
    right: 20px;
}
::v-deep .el-card {
    padding-top: 0px;
}
.app-detail {
    max-height: calc(100vh - 180px);
    overflow: auto;
}
.result-tag-red {
    width: 36px;
    height: 18px;
    font-size: 12px;
    font-weight: 400;
    color: #eb5648;
    background: rgba(235, 86, 72, 0.08);
    line-height: 18px;
    border-radius: 2px;
}
.result-tag-green {
    width: 40px;
    height: 20px;
    font-size: 12px;
    font-weight: 400;
    color: #20b09f;
    line-height: 18px;
    background: rgba(32, 176, 159, 0.08);
    border-radius: 2px;
}

.result-tag-yellow {
    width: 40px;
    height: 20px;
    font-size: 12px;
    font-weight: 400;
    color: #dbcd0c;
    line-height: 18px;
    background: rgba(236, 175, 7, 0.08);
    border-radius: 2px;
}

.size12 {
    font-size: 12px;
}
::v-deep input::-webkit-outer-spin-button,
::v-deep input::-webkit-inner-spin-button {
    -webkit-appearance: none !important;
}
::v-deep input[type='number'] {
    -moz-appearance: textfield !important;
}
::v-deep .rowHighLight {
    background: oldlace;
}
::v-deep .el-form-item {
    margin-bottom: 3px !important;
}

.projectAddBtn{
    margin: 0 5px;
    font-size: .9rem;
    cursor: pointer;
    &:hover{
        color: #0b7be3;
    }
}
::v-deep .table-hidden-row{
    display:none;
}
</style>
